diff --git a/Wox.Core/Configuration/Portable.cs b/Wox.Core/Configuration/Portable.cs index d2ce2f1a2..6eb7e768d 100644 --- a/Wox.Core/Configuration/Portable.cs +++ b/Wox.Core/Configuration/Portable.cs @@ -133,7 +133,7 @@ namespace Wox.Core.Configuration public void IndicateDeletion(string filePathTodelete) { - using (StreamWriter sw = File.CreateText(filePathTodelete + "\\.dead")){} + using (StreamWriter sw = File.CreateText(filePathTodelete + "\\" + DataLocation.DeletionIndicatorFile)){} } public void CleanUpFolderAfterPortabilityUpdate() @@ -144,10 +144,10 @@ namespace Wox.Core.Configuration bool DataLocationPortableDeleteRequired = false; bool DataLocationRoamingDeleteRequired = false; - if ((roamingDataPath + "\\.dead").FileExits()) + if ((roamingDataPath + "\\" + DataLocation.DeletionIndicatorFile).FileExits()) DataLocationRoamingDeleteRequired = true; - if ((portableDataPath + "\\.dead").FileExits()) + if ((portableDataPath + "\\" + DataLocation.DeletionIndicatorFile).FileExits()) DataLocationPortableDeleteRequired = true; if (DataLocationRoamingDeleteRequired) diff --git a/Wox.Core/Updater.cs b/Wox.Core/Updater.cs index b05984494..6a04def9f 100644 --- a/Wox.Core/Updater.cs +++ b/Wox.Core/Updater.cs @@ -81,7 +81,7 @@ namespace Wox.Core await updateManager.ApplyReleases(newUpdateInfo); - if (DataLocation.PortableDataLocationInUse) + if (DataLocation.PortableDataLocationInUse()) { var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}"; FilesFolders.Copy(DataLocation.PortableDataPath, targetDestination); diff --git a/Wox.Infrastructure/UserSettings/DataLocation.cs b/Wox.Infrastructure/UserSettings/DataLocation.cs index f100cdfeb..ef85341c5 100644 --- a/Wox.Infrastructure/UserSettings/DataLocation.cs +++ b/Wox.Infrastructure/UserSettings/DataLocation.cs @@ -9,21 +9,24 @@ namespace Wox.Infrastructure.UserSettings { public static class DataLocation { - public static bool PortableDataLocationInUse; public const string PortableFolderName = "UserData"; + public const string DeletionIndicatorFile = ".dead"; public static string PortableDataPath = Path.Combine(Constant.ProgramDirectory, PortableFolderName); public static string RoamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Constant.Wox); public static string DataDirectory() { - if (Directory.Exists(PortableDataPath)) - { - PortableDataLocationInUse = true; + if (PortableDataLocationInUse()) return PortableDataPath; - } - else - { - return RoamingDataPath; - } + + return RoamingDataPath; + } + + public static bool PortableDataLocationInUse() + { + if (Directory.Exists(PortableDataPath) && !File.Exists(DeletionIndicatorFile)) + return true; + + return false; } public static readonly string PluginsDirectory = Path.Combine(DataDirectory(), Constant.Plugins); diff --git a/Wox.Infrastructure/UserSettings/Settings.cs b/Wox.Infrastructure/UserSettings/Settings.cs index 487bf7d12..9d8e46ae6 100644 --- a/Wox.Infrastructure/UserSettings/Settings.cs +++ b/Wox.Infrastructure/UserSettings/Settings.cs @@ -77,7 +77,7 @@ namespace Wox.Infrastructure.UserSettings public bool DontPromptUpdateMsg { get; set; } public bool EnableUpdateLog { get; set; } - public bool PortableMode { get; set; } = false; + public bool PortableMode { get; set; } = DataLocation.PortableDataLocationInUse(); public bool StartWoxOnSystemStartup { get; set; } = true; public bool HideOnStartup { get; set; }