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 ();
|
NSApplication.Init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Let's use the bundled git first
|
// Let's use the bundled git first
|
||||||
SparkleLib.Git.SparkleGit.GitPath =
|
SparkleLib.Git.SparkleGit.GitPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "git", "libexec", "git-core", "git");
|
||||||
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.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
|
// we call out to an applescript to do the job
|
||||||
Process process = new Process ();
|
Process process = new Process ();
|
||||||
process.StartInfo.FileName = "osascript";
|
process.StartInfo.FileName = "osascript";
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
|
|
||||||
process.StartInfo.Arguments = "-e 'tell application \"System Events\" to " +
|
process.StartInfo.Arguments = "-e 'tell application \"System Events\" to " +
|
||||||
"make login item at end with properties {path:\"" + NSBundle.MainBundle.BundlePath + "\", hidden:false}'";
|
"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)) {
|
if (!Directory.Exists (Program.Controller.FoldersPath)) {
|
||||||
Directory.CreateDirectory (Program.Controller.FoldersPath);
|
Directory.CreateDirectory (Program.Controller.FoldersPath);
|
||||||
|
|
||||||
|
NSWorkspace.SharedWorkspace.SetIconforFile (NSImage.ImageNamed ("sparkleshare-folder.icns"),
|
||||||
|
Program.Controller.FoldersPath, 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,8 @@ namespace SparkleShare {
|
||||||
private Object repo_lock = new Object ();
|
private Object repo_lock = new Object ();
|
||||||
private Object check_repos_lock = new Object ();
|
private Object check_repos_lock = new Object ();
|
||||||
|
|
||||||
|
private bool lost_folders_path = false;
|
||||||
|
|
||||||
|
|
||||||
public SparkleControllerBase ()
|
public SparkleControllerBase ()
|
||||||
{
|
{
|
||||||
|
@ -178,10 +180,15 @@ namespace SparkleShare {
|
||||||
SparklePlugin.PluginsPath = PluginsPath;
|
SparklePlugin.PluginsPath = PluginsPath;
|
||||||
InstallProtocolHandler ();
|
InstallProtocolHandler ();
|
||||||
|
|
||||||
|
try {
|
||||||
// Create the SparkleShare folder and add it to the bookmarks
|
// Create the SparkleShare folder and add it to the bookmarks
|
||||||
if (CreateSparkleShareFolder ())
|
if (CreateSparkleShareFolder ())
|
||||||
AddToBookmarks ();
|
AddToBookmarks ();
|
||||||
|
|
||||||
|
} catch (DirectoryNotFoundException) {
|
||||||
|
this.lost_folders_path = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (FirstRun) {
|
if (FirstRun) {
|
||||||
this.config.SetConfigOption ("notifications", bool.TrueString);
|
this.config.SetConfigOption ("notifications", bool.TrueString);
|
||||||
|
|
||||||
|
@ -237,6 +244,13 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void UIHasLoaded ()
|
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) {
|
if (FirstRun) {
|
||||||
ShowSetupWindow (PageType.Setup);
|
ShowSetupWindow (PageType.Setup);
|
||||||
|
|
||||||
|
|
|
@ -132,8 +132,8 @@ namespace SparkleShare {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Directory.CreateDirectory (FoldersPath);
|
Directory.CreateDirectory (FoldersPath);
|
||||||
File.SetAttributes (FoldersPath, File.GetAttributes (FoldersPath) | FileAttributes.System);
|
|
||||||
|
|
||||||
|
File.SetAttributes (FoldersPath, File.GetAttributes (FoldersPath) | FileAttributes.System);
|
||||||
SparkleLogger.LogInfo ("Config", "Created '" + FoldersPath + "'");
|
SparkleLogger.LogInfo ("Config", "Created '" + FoldersPath + "'");
|
||||||
|
|
||||||
string app_path = Path.GetDirectoryName (Forms.Application.ExecutablePath);
|
string app_path = Path.GetDirectoryName (Forms.Application.ExecutablePath);
|
||||||
|
@ -155,8 +155,7 @@ namespace SparkleShare {
|
||||||
File.GetAttributes (ini_file_path) | FileAttributes.Hidden | FileAttributes.System);
|
File.GetAttributes (ini_file_path) | FileAttributes.Hidden | FileAttributes.System);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
SparkleLogger.LogInfo ("Config",
|
SparkleLogger.LogInfo ("Config", "Failed setting icon for '" + FoldersPath + "': " + e.Message);
|
||||||
"Failed setting icon for '" + FoldersPath + "': " + e.Message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue