After restart, clean up data folder locations so only one is used

This commit is contained in:
Jeremy Wu 2020-03-05 23:20:55 +11:00
parent 7ac69f9bcd
commit 56b8b5f3d6
2 changed files with 36 additions and 0 deletions

View file

@ -129,6 +129,40 @@ namespace Wox.Core.Configuration
key.SetValue("DisplayIcon", Constant.ApplicationDirectory + "\\app.ico", RegistryValueKind.String);
portabilityUpdater.CreateUninstallerRegistryEntry().Wait();
public void CleanUpFolderAfterPortabilityUpdate()
{
var portableDataPath = Path.Combine(Directory.GetParent(Assembly.GetExecutingAssembly().Location.NonNull()).ToString(), "UserData");
var roamingDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Wox");
bool DataLocationPortableDeleteRequired = false;
bool DataLocationRoamingDeleteRequired = false;
if ((roamingDataPath + "\\.dead").FileExits())
DataLocationRoamingDeleteRequired = true;
if ((portableDataPath + "\\.dead").FileExits())
DataLocationPortableDeleteRequired = true;
if (DataLocationRoamingDeleteRequired)
{
if(roamingDataPath.LocationExists())
MessageBox.Show("Wox detected you restarted after enabling portable mode, " +
"your roaming data profile will now be deleted");
FilesFolders.RemoveFolderIfExists(roamingDataPath);
return;
}
if(DataLocationPortableDeleteRequired)
{
MessageBox.Show("Wox detected you restarted after disabling portable mode, " +
"your portable data profile will now be deleted");
FilesFolders.RemoveFolderIfExists(portableDataPath);
return;
}
}
}
}

View file

@ -48,6 +48,8 @@ namespace Wox
{
Stopwatch.Normal("|App.OnStartup|Startup cost", () =>
{
_portable.CleanUpFolderAfterPortabilityUpdate();
Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------");
Log.Info($"|App.OnStartup|Runtime info:{ErrorReporting.RuntimeInfo()}");
RegisterAppDomainExceptions();