windows: Add migration code to use ~/SparkleShare instead of ~/My Documents/SparkleShare
This commit is contained in:
parent
8bff4c7b8b
commit
85bec2210a
|
@ -40,10 +40,21 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public string HomePath {
|
public string HomePath {
|
||||||
get {
|
get {
|
||||||
if (GetConfigOption ("home_path") != null)
|
if (GetConfigOption ("home_path") != null) {
|
||||||
return GetConfigOption ("home_path");
|
return GetConfigOption ("home_path");
|
||||||
else
|
|
||||||
return Environment.GetFolderPath (Environment.SpecialFolder.Personal);
|
} else {
|
||||||
|
try {
|
||||||
|
Environment.SpecialFolder folder =
|
||||||
|
(Environment.SpecialFolder) Enum.Parse (
|
||||||
|
typeof(Environment.SpecialFolder), "UserProfile");
|
||||||
|
|
||||||
|
return (Environment.GetFolderPath (folder));
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
return Environment.GetFolderPath (Environment.SpecialFolder.Personal);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +69,29 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public SparkleConfig (string config_path, string config_file_name)
|
public SparkleConfig (string config_path, string config_file_name)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
|
Environment.SpecialFolder folder =
|
||||||
|
(Environment.SpecialFolder) Enum.Parse(
|
||||||
|
typeof(Environment.SpecialFolder), "UserProfile");
|
||||||
|
|
||||||
|
string old_path = Path.Combine (
|
||||||
|
Environment.GetFolderPath (Environment.SpecialFolder.Personal), "SparkleShare");
|
||||||
|
|
||||||
|
if (Directory.Exists (old_path) &&
|
||||||
|
Environment.OSVersion.Platform == PlatformID.Win32NT) {
|
||||||
|
|
||||||
|
string new_path = Path.Combine (Environment.GetFolderPath (folder), "SparkleShare");
|
||||||
|
Directory.Move (old_path, new_path);
|
||||||
|
|
||||||
|
Console.WriteLine ("Migrated SparkleShare folder to %USERPROFILE%");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine ("Failed to migrate: " + e.Message);
|
||||||
|
// TODO: Remove this block when most people have migrated to the new path
|
||||||
|
}
|
||||||
|
|
||||||
FullPath = Path.Combine (config_path, config_file_name);
|
FullPath = Path.Combine (config_path, config_file_name);
|
||||||
LogFilePath = Path.Combine (config_path, "debug.log");
|
LogFilePath = Path.Combine (config_path, "debug.log");
|
||||||
|
|
||||||
|
|
|
@ -235,9 +235,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
public void UIHasLoaded ()
|
public void UIHasLoaded ()
|
||||||
{
|
{
|
||||||
// if (FirstRun)
|
if (FirstRun)
|
||||||
ShowSetupWindow (PageType.Setup);
|
ShowSetupWindow (PageType.Setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -950,7 +950,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (!Directory.Exists (tmp_path)) {
|
if (!Directory.Exists (tmp_path)) {
|
||||||
Directory.CreateDirectory (tmp_path);
|
Directory.CreateDirectory (tmp_path);
|
||||||
File.SetAttributes (tmp_path, FileAttributes.Directory | FileAttributes.Hidden);
|
File.SetAttributes (tmp_path, // FIXME: Doesn't seem to be hidden
|
||||||
|
File.GetAttributes (tmp_path) | FileAttributes.Hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
string canonical_name = Path.GetFileNameWithoutExtension (remote_path);
|
string canonical_name = Path.GetFileNameWithoutExtension (remote_path);
|
||||||
|
|
|
@ -108,9 +108,13 @@ namespace SparkleShare {
|
||||||
string startup_folder_path = Environment.GetFolderPath (
|
string startup_folder_path = Environment.GetFolderPath (
|
||||||
Environment.SpecialFolder.Startup);
|
Environment.SpecialFolder.Startup);
|
||||||
|
|
||||||
string shortcut_path = Path.Combine (startup_folder_path, "SparkleShare.lnk");
|
string shortcut_path = Path.Combine (startup_folder_path, "SparkleShare.lnk");
|
||||||
string shortcut_target = Forms.Application.ExecutablePath;
|
|
||||||
|
if (File.Exists (shortcut_path))
|
||||||
|
File.Delete (shortcut_path);
|
||||||
|
|
||||||
|
string shortcut_target = Forms.Application.ExecutablePath;
|
||||||
|
|
||||||
Shortcut shortcut = new Shortcut ();
|
Shortcut shortcut = new Shortcut ();
|
||||||
shortcut.Create (shortcut_path, shortcut_target);
|
shortcut.Create (shortcut_path, shortcut_target);
|
||||||
}
|
}
|
||||||
|
@ -146,6 +150,10 @@ namespace SparkleShare {
|
||||||
Environment.SpecialFolder.UserProfile);
|
Environment.SpecialFolder.UserProfile);
|
||||||
|
|
||||||
string shortcut_path = Path.Combine (user_profile_path, "Links", "SparkleShare.lnk");
|
string shortcut_path = Path.Combine (user_profile_path, "Links", "SparkleShare.lnk");
|
||||||
|
|
||||||
|
if (File.Exists (shortcut_path))
|
||||||
|
File.Delete (shortcut_path);
|
||||||
|
|
||||||
string shortcut_target = SparkleConfig.DefaultConfig.FoldersPath;
|
string shortcut_target = SparkleConfig.DefaultConfig.FoldersPath;
|
||||||
|
|
||||||
Shortcut shortcut = new Shortcut ();
|
Shortcut shortcut = new Shortcut ();
|
||||||
|
|
Loading…
Reference in a new issue