Change PortableDataLocationInUse property to method

Added const for deletion indicator
This commit is contained in:
Jeremy Wu 2020-03-06 21:28:01 +11:00
parent d0976a99c9
commit ef1b52122e
4 changed files with 17 additions and 14 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -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; }