mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-11 09:49:22 +08: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:
parent
22f8390ef9
commit
87f6278bf9
@ -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";
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user