controller: don't crash when the SparkleShare folder is on an unmounted drive
This commit is contained in:
parent
e32f45214c
commit
3001e1c2c1
|
@ -55,13 +55,9 @@ namespace SparkleShare {
|
|||
NSApplication.Init ();
|
||||
}
|
||||
|
||||
|
||||
// Let's use the bundled git first
|
||||
SparkleLib.Git.SparkleGit.GitPath =
|
||||
Path.Combine (NSBundle.MainBundle.ResourcePath, "git", "libexec", "git-core", "git");
|
||||
|
||||
SparkleLib.Git.SparkleGit.ExecPath =
|
||||
Path.Combine (NSBundle.MainBundle.ResourcePath, "git", "libexec", "git-core");
|
||||
SparkleLib.Git.SparkleGit.GitPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "git", "libexec", "git-core", "git");
|
||||
SparkleLib.Git.SparkleGit.ExecPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "git", "libexec", "git-core");
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,9 +88,7 @@ namespace SparkleShare {
|
|||
// we call out to an applescript to do the job
|
||||
Process process = new Process ();
|
||||
process.StartInfo.FileName = "osascript";
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
|
||||
process.StartInfo.Arguments = "-e 'tell application \"System Events\" to " +
|
||||
"make login item at end with properties {path:\"" + NSBundle.MainBundle.BundlePath + "\", hidden:false}'";
|
||||
|
||||
|
@ -170,11 +164,15 @@ namespace SparkleShare {
|
|||
|
||||
if (!Directory.Exists (Program.Controller.FoldersPath)) {
|
||||
Directory.CreateDirectory (Program.Controller.FoldersPath);
|
||||
|
||||
NSWorkspace.SharedWorkspace.SetIconforFile (NSImage.ImageNamed ("sparkleshare-folder.icns"),
|
||||
Program.Controller.FoldersPath, 0);
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -161,6 +161,8 @@ namespace SparkleShare {
|
|||
private Object repo_lock = new Object ();
|
||||
private Object check_repos_lock = new Object ();
|
||||
|
||||
private bool lost_folders_path = false;
|
||||
|
||||
|
||||
public SparkleControllerBase ()
|
||||
{
|
||||
|
@ -178,10 +180,15 @@ namespace SparkleShare {
|
|||
SparklePlugin.PluginsPath = PluginsPath;
|
||||
InstallProtocolHandler ();
|
||||
|
||||
try {
|
||||
// Create the SparkleShare folder and add it to the bookmarks
|
||||
if (CreateSparkleShareFolder ())
|
||||
AddToBookmarks ();
|
||||
|
||||
} catch (DirectoryNotFoundException) {
|
||||
this.lost_folders_path = true;
|
||||
}
|
||||
|
||||
if (FirstRun) {
|
||||
this.config.SetConfigOption ("notifications", bool.TrueString);
|
||||
|
||||
|
@ -237,6 +244,13 @@ namespace SparkleShare {
|
|||
|
||||
public void UIHasLoaded ()
|
||||
{
|
||||
if (this.lost_folders_path) {
|
||||
Program.UI.Bubbles.Controller.ShowBubble ("Where's your SparkleShare folder?",
|
||||
"Did you put it on a disattached drive?", null);
|
||||
|
||||
Environment.Exit (-1);
|
||||
}
|
||||
|
||||
if (FirstRun) {
|
||||
ShowSetupWindow (PageType.Setup);
|
||||
|
||||
|
|
|
@ -132,8 +132,8 @@ namespace SparkleShare {
|
|||
return false;
|
||||
|
||||
Directory.CreateDirectory (FoldersPath);
|
||||
File.SetAttributes (FoldersPath, File.GetAttributes (FoldersPath) | FileAttributes.System);
|
||||
|
||||
File.SetAttributes (FoldersPath, File.GetAttributes (FoldersPath) | FileAttributes.System);
|
||||
SparkleLogger.LogInfo ("Config", "Created '" + FoldersPath + "'");
|
||||
|
||||
string app_path = Path.GetDirectoryName (Forms.Application.ExecutablePath);
|
||||
|
@ -155,8 +155,7 @@ namespace SparkleShare {
|
|||
File.GetAttributes (ini_file_path) | FileAttributes.Hidden | FileAttributes.System);
|
||||
|
||||
} catch (IOException e) {
|
||||
SparkleLogger.LogInfo ("Config",
|
||||
"Failed setting icon for '" + FoldersPath + "': " + e.Message);
|
||||
SparkleLogger.LogInfo ("Config", "Failed setting icon for '" + FoldersPath + "': " + e.Message);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue