Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 32 additions & 27 deletions Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
get
{
var size = GetCacheFiles().Sum(file => file.Length);
return $"{App.API.GetTranslation("clearcachefolder")} ({BytesToReadableString(size)})";

Check warning on line 37 in Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`clearcachefolder` is not a recognized word. (unrecognized-spelling)
}
}

Expand Down Expand Up @@ -107,7 +107,7 @@
{
if (!ClearLogFolder())
{
App.API.ShowMsgBox(App.API.GetTranslation("clearfolderfailMessage"));

Check warning on line 110 in Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`clearfolderfail` is not a recognized word. (unrecognized-spelling)
}
}
}
Expand All @@ -116,8 +116,8 @@
private void AskClearCacheFolderConfirmation()
{
var confirmResult = App.API.ShowMsgBox(
App.API.GetTranslation("clearcachefolderMessage"),

Check warning on line 119 in Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`clearcachefolder` is not a recognized word. (unrecognized-spelling)

Check warning on line 119 in Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`clearcachefolder` is not a recognized word. (unrecognized-spelling)
App.API.GetTranslation("clearcachefolder"),

Check warning on line 120 in Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`clearcachefolder` is not a recognized word. (unrecognized-spelling)

Check warning on line 120 in Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`clearcachefolder` is not a recognized word. (unrecognized-spelling)
MessageBoxButton.YesNo
);

Expand All @@ -125,7 +125,7 @@
{
if (!ClearCacheFolder())
{
App.API.ShowMsgBox(App.API.GetTranslation("clearfolderfailMessage"));

Check warning on line 128 in Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`clearfolderfail` is not a recognized word. (unrecognized-spelling)

Check warning on line 128 in Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`clearfolderfail` is not a recognized word. (unrecognized-spelling)
}
}
}
Expand Down Expand Up @@ -231,36 +231,41 @@
}
});

// Firstly, delete plugin cache directories
pluginCacheDirectory.EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
.ToList()
.ForEach(dir =>
{
try
{
// Plugin may create directories in its cache directory
dir.Delete(recursive: true);
}
catch (Exception e)
// Check if plugin cache directory exists before attempting to delete
// Or it will throw DirectoryNotFoundException in `pluginCacheDirectory.EnumerateDirectories`
if (pluginCacheDirectory.Exists)
{
// Firstly, delete plugin cache directories
pluginCacheDirectory.EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
.ToList()
.ForEach(dir =>
{
App.API.LogException(ClassName, $"Failed to delete cache directory: {dir.Name}", e);
success = false;
}
});
try
{
// Plugin may create directories in its cache directory
dir.Delete(recursive: true);
}
catch (Exception e)
{
App.API.LogException(ClassName, $"Failed to delete cache directory: {dir.Name}", e);
success = false;
}
});

// Then, delete plugin directory
var dir = pluginCacheDirectory;
try
{
dir.Delete(recursive: false);
}
catch (Exception e)
{
App.API.LogException(ClassName, $"Failed to delete cache directory: {dir.Name}", e);
success = false;
}

// Then, delete plugin directory
var dir = GetPluginCacheDir();
try
{
dir.Delete(recursive: false);
OnPropertyChanged(nameof(CacheFolderSize));
}
catch (Exception e)
{
App.API.LogException(ClassName, $"Failed to delete cache directory: {dir.Name}", e);
success = false;
}

OnPropertyChanged(nameof(CacheFolderSize));

return success;
}
Expand Down
Loading