Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/Languages/lang_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@
"Uninstall Scoop (and its packages)": "Uninstall Scoop (and its packages)",
"Run cleanup and clear cache": "Run cleanup and clear cache",
"Run": "Run",
"Enable Scoop cleanup on launch": "Enable Scoop cleanup on launch",
"Clear Scoop download cache on launch": "Clear Scoop download cache on launch",
"Clean up older Scoop app versions on launch": "Clean up older Scoop app versions on launch",
"Default vcpkg triplet": "Default vcpkg triplet",
"Change vcpkg root location": "Change vcpkg root location",
"Reset vcpkg root location": "Reset vcpkg root location",
Expand Down
3 changes: 2 additions & 1 deletion src/Languages/lang_zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@
"Uninstall Scoop (and its packages)": "卸载 Scoop(及其软件包)",
"Run cleanup and clear cache": "运行清理并清除缓存",
"Run": "运行",
"Enable Scoop cleanup on launch": "打开程序时清理 Scoop",
"Clear Scoop download cache on launch": "启动时清除 Scoop 下载缓存",
"Clean up older Scoop app versions on launch": "启动时清理 Scoop 旧版应用",
"Default vcpkg triplet": "默认 vcpkg triplet",
"Change vcpkg root location": "更改 vcpkg 根目录位置",
"Reset vcpkg root location": "重置 vcpkg 根目录位置",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,22 @@ private void BuildExtraControls(CheckboxCard_Dict disableNotifsCard)
scoopCleanup.Click += (_, _) => ViewModel.ScoopCleanupCommand.Execute(null);
ExtraControls.Children.Add(scoopCleanup);

// Clear download cache on launch
ExtraControls.Children.Add(new CheckboxCard
{
CornerRadius = new CornerRadius(0),
BorderThickness = new Thickness(1, 0, 1, 0),
SettingName = CoreSettings.K.EnableScoopCleanupCache,
Text = CoreTools.AutoTranslated("Clear Scoop download cache on launch"),
});

// Clean up older app versions on launch
ExtraControls.Children.Add(new CheckboxCard
{
CornerRadius = new CornerRadius(0, 0, 8, 8),
BorderThickness = new Thickness(1, 0, 1, 1),
SettingName = CoreSettings.K.EnableScoopCleanup,
Text = CoreTools.AutoTranslated("Enable Scoop cleanup on launch"),
SettingName = CoreSettings.K.EnableScoopCleanupApps,
Text = CoreTools.AutoTranslated("Clean up older Scoop app versions on launch"),
});
break;

Expand Down
4 changes: 4 additions & 0 deletions src/UniGetUI.Core.Settings/SettingsEngine_Names.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public enum K
DisableTimeoutOnPackageListingTasks,
RemoveAllDesktopShortcuts,
EnableScoopCleanup,
EnableScoopCleanupCache,
EnableScoopCleanupApps,
IgnoreUpdatesNotApplicable,
DisableNewWinGetTroubleshooter,
DisableUpdateVcpkgGitPorts,
Expand Down Expand Up @@ -126,6 +128,8 @@ public static string ResolveKey(K key)
K.DisableTimeoutOnPackageListingTasks => "DisableTimeoutOnPackageListingTasks",
K.RemoveAllDesktopShortcuts => "RemoveAllDesktopShortcuts",
K.EnableScoopCleanup => "EnableScoopCleanup",
K.EnableScoopCleanupCache => "EnableScoopCleanupCache",
K.EnableScoopCleanupApps => "EnableScoopCleanupApps",
K.IgnoreUpdatesNotApplicable => "IgnoreUpdatesNotApplicable",
K.DisableNewWinGetTroubleshooter => "DisableNewWinGetTroubleshooter",
K.DisableUpdateVcpkgGitPorts => "DisableUpdateVcpkgGitPorts",
Expand Down
17 changes: 13 additions & 4 deletions src/UniGetUI.Interface.IpcApi/IpcManagerMaintenanceApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,26 @@ await RunWindowsProcessAsync(
throw new InvalidOperationException("Scoop is not ready.");
}

// Clean old app versions (user scope)
await RunWindowsProcessAsync(
manager.Status.ExecutablePath,
manager.Status.ExecutableCallArgs + " cache rm *"
manager.Status.ExecutableCallArgs + " cleanup --all"
);
// Clean old app versions (global scope, needs admin)
await RunWindowsProcessAsync(
manager.Status.ExecutablePath,
manager.Status.ExecutableCallArgs + " cleanup --all --cache"
manager.Status.ExecutableCallArgs + " cleanup --all --global",
runAsAdmin: true
);
// Clear download cache (user scope)
await RunWindowsProcessAsync(
manager.Status.ExecutablePath,
manager.Status.ExecutableCallArgs + " cache rm --all"
);
// Clear download cache (global scope, needs admin)
await RunWindowsProcessAsync(
manager.Status.ExecutablePath,
manager.Status.ExecutableCallArgs + " cleanup --all --global --cache",
manager.Status.ExecutableCallArgs + " cache rm --all --global",
runAsAdmin: true
);
await ReloadManagerAsync(manager);
Expand Down Expand Up @@ -284,7 +293,7 @@ private static IpcManagerMaintenanceInfo ToMaintenanceInfo(IPackageManager manag
? true
: null,
ScoopCleanupOnLaunch = manager.Name.Equals("Scoop", StringComparison.OrdinalIgnoreCase)
? Settings.Get(Settings.K.EnableScoopCleanup)
? Settings.Get(Settings.K.EnableScoopCleanupCache) || Settings.Get(Settings.K.EnableScoopCleanupApps) || Settings.Get(Settings.K.EnableScoopCleanup)
: null,
UpdateNotificationsSuppressed = Settings.GetDictionaryItem<string, bool>(
Settings.K.DisabledPackageManagerNotifications,
Expand Down
35 changes: 26 additions & 9 deletions src/UniGetUI.PackageEngine.Managers.Scoop/Scoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,11 @@ protected override void _loadManagerVersion(out string version)

protected override void _performExtraLoadingSteps()
{
if (Settings.Get(Settings.K.EnableScoopCleanup))
// Backward compatibility: if old setting is on, enable both new ones
bool enableCacheCleanup = Settings.Get(Settings.K.EnableScoopCleanupCache) || Settings.Get(Settings.K.EnableScoopCleanup);
bool enableAppsCleanup = Settings.Get(Settings.K.EnableScoopCleanupApps) || Settings.Get(Settings.K.EnableScoopCleanup);

if (enableCacheCleanup || enableAppsCleanup)
{
RunCleanup();
}
Expand All @@ -583,14 +587,27 @@ protected override void _performExtraLoadingSteps()
private async Task _runCleanup()
{
Logger.Info("Starting scoop cleanup...");
foreach (
string command in new[]
{
" cache rm *",
" cleanup --all --cache",
" cleanup --all --global --cache",
}
)
var commands = new List<string>();

// Backward compatibility: if old setting is on, enable both
bool enableCacheCleanup = Settings.Get(Settings.K.EnableScoopCleanupCache) || Settings.Get(Settings.K.EnableScoopCleanup);
bool enableAppsCleanup = Settings.Get(Settings.K.EnableScoopCleanupApps) || Settings.Get(Settings.K.EnableScoopCleanup);

// Clean old app versions (scoop cleanup --all)
if (enableAppsCleanup)
{
commands.Add(" cleanup --all");
commands.Add(" cleanup --all --global");
}

// Clear download cache (scoop cache rm --all)
if (enableCacheCleanup)
{
commands.Add(" cache rm --all");
commands.Add(" cache rm --all --global");
}

foreach (string command in commands)
{
using Process p = new()
{
Expand Down