Skip to content

Commit 82a24c9

Browse files
committed
Add validation prior to update portability
1 parent 930ceef commit 82a24c9

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

Wox.Core/Configuration/IPortable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-

1+
22
namespace Wox.Core.Configuration
33
{
44
public interface IPortable
@@ -12,6 +12,6 @@ public interface IPortable
1212
bool IsPortableModeEnabled();
1313
void MoveUserDataFolder(string fromLocation, string toLocation);
1414
void VerifyUserDataAfterMove(string fromLocation, string toLocation);
15-
void CleanUpFolderAfterPortabilityUpdate();
15+
bool CanUpdatePortability();
1616
}
1717
}

Wox.Core/Configuration/Portable.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,22 @@ public void PreStartCleanUpAfterPortabilityUpdate()
171171
return;
172172
}
173173
}
174+
175+
public bool CanUpdatePortability()
176+
{
177+
var roamingLocationExists = DataLocation.RoamingDataPath.LocationExists();
178+
var portableLocationExists = DataLocation.PortableDataPath.LocationExists();
179+
180+
if(roamingLocationExists && portableLocationExists)
181+
{
182+
MessageBox.Show(string.Format("Wox detected your user data exists both in {0} and " +
183+
"{1}. {2}{2}Please delete {1} in order to proceed. No changes have occured.",
184+
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
185+
186+
return false;
187+
}
188+
189+
return true;
190+
}
174191
}
175192
}

Wox/ViewModel/SettingWindowViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public bool PortableMode
5454
get { return _portableMode; }
5555
set
5656
{
57+
if (!_portable.CanUpdatePortability())
58+
return;
59+
5760
_portableMode = value;
5861

5962
Settings.PortableMode = value;

0 commit comments

Comments
 (0)