Standardize Image Resizer naming (#14694)

* Standardize Image Resizer naming

* Use no-throw methods

* Do not move if new dir already exist

* Update test files paths
This commit is contained in:
Stefan Markovic 2021-12-02 09:08:43 +01:00 committed by GitHub
parent 22f8390ef9
commit 87f6278bf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 26 additions and 9 deletions

View File

@ -7,5 +7,6 @@ namespace ImageResizerConstants
inline const std::wstring ModuleKey = L"Image Resizer";
// Name of the ImageResizer save folder.
inline const std::wstring ModuleOldSaveFolderKey = L"ImageResizer";
inline const std::wstring ModuleSaveFolderKey = L"Image Resizer";
}

View File

@ -45,8 +45,16 @@ namespace
CSettings::CSettings()
{
std::wstring result = PTSettingsHelper::get_module_save_folder_location(ImageResizerConstants::ModuleSaveFolderKey);
jsonFilePath = result + std::wstring(c_imageResizerDataFilePath);
std::wstring oldSavePath = PTSettingsHelper::get_module_save_folder_location(ImageResizerConstants::ModuleOldSaveFolderKey);
std::wstring savePath = PTSettingsHelper::get_module_save_folder_location(ImageResizerConstants::ModuleSaveFolderKey);
std::error_code ec;
if (std::filesystem::exists(oldSavePath, ec))
{
std::filesystem::copy(oldSavePath, savePath, std::filesystem::copy_options::recursive, ec);
std::filesystem::remove_all(oldSavePath, ec);
}
jsonFilePath = savePath + std::wstring(c_imageResizerDataFilePath);
Load();
}

View File

@ -422,6 +422,14 @@ namespace ImageResizer.Properties
public void Reload()
{
string oldSettingsDir = _fileSystem.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "ImageResizer");
string settingsDir = _fileSystem.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Microsoft", "PowerToys", "Image Resizer");
if (_fileSystem.Directory.Exists(oldSettingsDir) && !_fileSystem.Directory.Exists(settingsDir))
{
_fileSystem.Directory.Move(oldSettingsDir, settingsDir);
}
_jsonMutex.WaitOne();
if (!_fileSystem.File.Exists(SettingsPath))
{