Add disable portable mode code

This commit is contained in:
Jeremy Wu 2020-02-24 21:42:41 +11:00
parent ba46ce09dc
commit 61845dd0db
2 changed files with 35 additions and 1 deletions

View file

@ -7,6 +7,8 @@ namespace Wox.Core.Configuration
void DisablePortableMode();
void RemoveShortcuts();
void RemoveUninstallerEntry();
void CreateShortcuts();
void CreateUninstallerEntry();
bool IsPortableModeEnabled();
void MoveUserDataFolder(string fromLocation, string toLocation);
void VerifyUserDataAfterMove(string fromLocation, string toLocation);

View file

@ -27,7 +27,25 @@ namespace Wox.Core.Configuration
public void DisablePortableMode()
{
throw new NotImplementedException();
try
{
MoveUserDataFolder(portableDataPath, roamingDataPath);
CreateShortcuts();
CreateUninstallerEntry();
// always dispose UpdateManager???????????
// CHANGE TO PRIVATE/INTERNAL METHODS
}
catch (Exception e)
{
//log and update error message to output above locations where shortcuts may not have been removed
#if DEBUG
throw;
#else
throw;// PRODUCTION LOGGING AND CONTINUE
#endif
}
}
public void EnablePortableMode()
@ -37,6 +55,8 @@ namespace Wox.Core.Configuration
MoveUserDataFolder(roamingDataPath, portableDataPath);
RemoveShortcuts();
RemoveUninstallerEntry();
// always dispose UpdateManager???????????
}
catch (Exception e)
{
@ -78,5 +98,17 @@ namespace Wox.Core.Configuration
{
FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation);
}
public void CreateShortcuts()
{
portabilityUpdater.CreateShortcutsForExecutable(exeName, ShortcutLocation.StartMenu, false);
portabilityUpdater.CreateShortcutsForExecutable(exeName, ShortcutLocation.Desktop, false);
portabilityUpdater.CreateShortcutsForExecutable(exeName, ShortcutLocation.Startup, false);
}
public void CreateUninstallerEntry()
{
portabilityUpdater.CreateUninstallerRegistryEntry();
}
}
}