controller: don't crash when the SparkleShare folder is on an unmounted drive
This commit is contained in:
parent
e32f45214c
commit
3001e1c2c1
|
@ -123,8 +123,8 @@ namespace SparkleShare {
|
||||||
bool folder_created = false;
|
bool folder_created = false;
|
||||||
|
|
||||||
if (!Directory.Exists (SparkleConfig.DefaultConfig.FoldersPath)) {
|
if (!Directory.Exists (SparkleConfig.DefaultConfig.FoldersPath)) {
|
||||||
Directory.CreateDirectory (SparkleConfig.DefaultConfig.FoldersPath);
|
Directory.CreateDirectory (SparkleConfig.DefaultConfig.FoldersPath);
|
||||||
SparkleLogger.LogInfo ("Controller", "Created '" + SparkleConfig.DefaultConfig.FoldersPath + "'");
|
SparkleLogger.LogInfo ("Controller", "Created '" + SparkleConfig.DefaultConfig.FoldersPath + "'");
|
||||||
|
|
||||||
folder_created = true;
|
folder_created = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,11 +87,9 @@ namespace SparkleShare {
|
||||||
// There aren't any bindings in MonoMac to support this yet, so
|
// There aren't any bindings in MonoMac to support this yet, so
|
||||||
// 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}'";
|
||||||
|
|
||||||
process.Start ();
|
process.Start ();
|
||||||
|
@ -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,9 +180,14 @@ namespace SparkleShare {
|
||||||
SparklePlugin.PluginsPath = PluginsPath;
|
SparklePlugin.PluginsPath = PluginsPath;
|
||||||
InstallProtocolHandler ();
|
InstallProtocolHandler ();
|
||||||
|
|
||||||
// Create the SparkleShare folder and add it to the bookmarks
|
try {
|
||||||
if (CreateSparkleShareFolder ())
|
// Create the SparkleShare folder and add it to the bookmarks
|
||||||
AddToBookmarks ();
|
if (CreateSparkleShareFolder ())
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
|
@ -131,9 +131,9 @@ namespace SparkleShare {
|
||||||
if (Directory.Exists (FoldersPath))
|
if (Directory.Exists (FoldersPath))
|
||||||
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