mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
fix<App>: fix crash reported by https://gitee.com/sourcegit/sourcegit/issues/I43W4I
This commit is contained in:
parent
7ab2c1017a
commit
d7290a9cf6
1 changed files with 23 additions and 21 deletions
|
@ -43,29 +43,31 @@ namespace SourceGit {
|
||||||
|
|
||||||
// 如果启动命令中指定了路径,打开指定目录的仓库
|
// 如果启动命令中指定了路径,打开指定目录的仓库
|
||||||
var launcher = new Views.Launcher();
|
var launcher = new Views.Launcher();
|
||||||
if (e.Args.Length > 0) {
|
if (Models.Preference.Instance.IsReady) {
|
||||||
var repo = Models.Preference.Instance.FindRepository(e.Args[0]);
|
if (e.Args.Length > 0) {
|
||||||
if (repo == null) {
|
var repo = Models.Preference.Instance.FindRepository(e.Args[0]);
|
||||||
var path = new Commands.GetRepositoryRootPath(e.Args[0]).Result();
|
if (repo == null) {
|
||||||
if (path != null) {
|
var path = new Commands.GetRepositoryRootPath(e.Args[0]).Result();
|
||||||
var gitDir = new Commands.QueryGitDir(path).Result();
|
if (path != null) {
|
||||||
repo = Models.Preference.Instance.AddRepository(path, gitDir, "");
|
var gitDir = new Commands.QueryGitDir(path).Result();
|
||||||
}
|
repo = Models.Preference.Instance.AddRepository(path, gitDir, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repo != null) Models.Watcher.Open(repo);
|
|
||||||
} else {
|
|
||||||
var restore = Models.Preference.Instance.Restore;
|
|
||||||
var actived = null as Models.Repository;
|
|
||||||
if (restore.IsEnabled && restore.Opened.Count > 0) {
|
|
||||||
foreach (var path in restore.Opened) {
|
|
||||||
if (!Directory.Exists(path)) continue;
|
|
||||||
var repo = Models.Preference.Instance.FindRepository(path);
|
|
||||||
if (repo != null) Models.Watcher.Open(repo);
|
|
||||||
if (path == restore.Actived) actived = repo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actived != null) Models.Watcher.Open(actived);
|
if (repo != null) Models.Watcher.Open(repo);
|
||||||
|
} else if (Models.Preference.Instance.Restore.IsEnabled) {
|
||||||
|
var restore = Models.Preference.Instance.Restore;
|
||||||
|
var actived = null as Models.Repository;
|
||||||
|
if (restore.Opened.Count > 0) {
|
||||||
|
foreach (var path in restore.Opened) {
|
||||||
|
if (!Directory.Exists(path)) continue;
|
||||||
|
var repo = Models.Preference.Instance.FindRepository(path);
|
||||||
|
if (repo != null) Models.Watcher.Open(repo);
|
||||||
|
if (path == restore.Actived) actived = repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actived != null) Models.Watcher.Open(actived);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue