windows: Add migration code to use ~/SparkleShare instead of ~/My Documents/SparkleShare
This commit is contained in:
parent
8bff4c7b8b
commit
85bec2210a
|
@ -40,12 +40,23 @@ namespace SparkleLib {
|
|||
|
||||
public string HomePath {
|
||||
get {
|
||||
if (GetConfigOption ("home_path") != null)
|
||||
if (GetConfigOption ("home_path") != null) {
|
||||
return GetConfigOption ("home_path");
|
||||
else
|
||||
|
||||
} else {
|
||||
try {
|
||||
Environment.SpecialFolder folder =
|
||||
(Environment.SpecialFolder) Enum.Parse (
|
||||
typeof(Environment.SpecialFolder), "UserProfile");
|
||||
|
||||
return (Environment.GetFolderPath (folder));
|
||||
|
||||
} catch {
|
||||
return Environment.GetFolderPath (Environment.SpecialFolder.Personal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FoldersPath {
|
||||
get {
|
||||
|
@ -58,6 +69,29 @@ namespace SparkleLib {
|
|||
|
||||
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);
|
||||
LogFilePath = Path.Combine (config_path, "debug.log");
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ namespace SparkleShare {
|
|||
|
||||
public void UIHasLoaded ()
|
||||
{
|
||||
// if (FirstRun)
|
||||
if (FirstRun)
|
||||
ShowSetupWindow (PageType.Setup);
|
||||
}
|
||||
|
||||
|
@ -950,7 +950,8 @@ namespace SparkleShare {
|
|||
|
||||
if (!Directory.Exists (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);
|
||||
|
|
|
@ -109,6 +109,10 @@ namespace SparkleShare {
|
|||
Environment.SpecialFolder.Startup);
|
||||
|
||||
string shortcut_path = Path.Combine (startup_folder_path, "SparkleShare.lnk");
|
||||
|
||||
if (File.Exists (shortcut_path))
|
||||
File.Delete (shortcut_path);
|
||||
|
||||
string shortcut_target = Forms.Application.ExecutablePath;
|
||||
|
||||
Shortcut shortcut = new Shortcut ();
|
||||
|
@ -146,6 +150,10 @@ namespace SparkleShare {
|
|||
Environment.SpecialFolder.UserProfile);
|
||||
|
||||
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;
|
||||
|
||||
Shortcut shortcut = new Shortcut ();
|
||||
|
|
Loading…
Reference in a new issue