mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
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:
@@ -7,5 +7,6 @@ namespace ImageResizerConstants
|
|||||||
inline const std::wstring ModuleKey = L"Image Resizer";
|
inline const std::wstring ModuleKey = L"Image Resizer";
|
||||||
|
|
||||||
// Name of the ImageResizer save folder.
|
// Name of the ImageResizer save folder.
|
||||||
|
inline const std::wstring ModuleOldSaveFolderKey = L"ImageResizer";
|
||||||
inline const std::wstring ModuleSaveFolderKey = L"Image Resizer";
|
inline const std::wstring ModuleSaveFolderKey = L"Image Resizer";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,16 @@ namespace
|
|||||||
|
|
||||||
CSettings::CSettings()
|
CSettings::CSettings()
|
||||||
{
|
{
|
||||||
std::wstring result = PTSettingsHelper::get_module_save_folder_location(ImageResizerConstants::ModuleSaveFolderKey);
|
std::wstring oldSavePath = PTSettingsHelper::get_module_save_folder_location(ImageResizerConstants::ModuleOldSaveFolderKey);
|
||||||
jsonFilePath = result + std::wstring(c_imageResizerDataFilePath);
|
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();
|
Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -422,6 +422,14 @@ namespace ImageResizer.Properties
|
|||||||
|
|
||||||
public void Reload()
|
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();
|
_jsonMutex.WaitOne();
|
||||||
if (!_fileSystem.File.Exists(SettingsPath))
|
if (!_fileSystem.File.Exists(SettingsPath))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user