Add validation prior to update portability

This commit is contained in:
Jeremy Wu 2020-03-06 23:45:52 +11:00
parent 930ceef55c
commit 82a24c9952
3 changed files with 22 additions and 2 deletions

View file

@ -1,4 +1,4 @@

namespace Wox.Core.Configuration
{
public interface IPortable
@ -12,6 +12,6 @@ namespace Wox.Core.Configuration
bool IsPortableModeEnabled();
void MoveUserDataFolder(string fromLocation, string toLocation);
void VerifyUserDataAfterMove(string fromLocation, string toLocation);
void CleanUpFolderAfterPortabilityUpdate();
bool CanUpdatePortability();
}
}

View file

@ -171,5 +171,22 @@ namespace Wox.Core.Configuration
return;
}
}
public bool CanUpdatePortability()
{
var roamingLocationExists = DataLocation.RoamingDataPath.LocationExists();
var portableLocationExists = DataLocation.PortableDataPath.LocationExists();
if(roamingLocationExists && portableLocationExists)
{
MessageBox.Show(string.Format("Wox detected your user data exists both in {0} and " +
"{1}. {2}{2}Please delete {1} in order to proceed. No changes have occured.",
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
return false;
}
return true;
}
}
}

View file

@ -54,6 +54,9 @@ namespace Wox.ViewModel
get { return _portableMode; }
set
{
if (!_portable.CanUpdatePortability())
return;
_portableMode = value;
Settings.PortableMode = value;