diff --git a/make_scripts/config/commonLocKeys.txt b/make_scripts/config/commonLocKeys.txt
index 9ff0273..3b05fac 100644
--- a/make_scripts/config/commonLocKeys.txt
+++ b/make_scripts/config/commonLocKeys.txt
@@ -117,3 +117,4 @@ LOCLegendaryMigratingGamesEpic
LOCLegendaryMigrationConfirm
LOCLegendaryInstanceNotice
LOCLegendaryLauncherUpdatePolicy
+LOCLegendaryAutoRemoveCompletedDownloads
diff --git a/src/Localization/en_US.xaml b/src/Localization/en_US.xaml
index e1f688e..cab947b 100644
--- a/src/Localization/en_US.xaml
+++ b/src/Localization/en_US.xaml
@@ -12,6 +12,7 @@
You won't have to choose anything in the installer window and the installation will start automatically after downloading the required information.
Maximum number of worker processes
Action after download is complete
+ Automatically remove completed downloads from list
System will be turned off soon...
System will be restarted soon...
System will be hibernated soon...
diff --git a/src/NileLibrary.cs b/src/NileLibrary.cs
index 38f365e..e1a2682 100644
--- a/src/NileLibrary.cs
+++ b/src/NileLibrary.cs
@@ -467,8 +467,8 @@ public bool StopDownloadManager(bool displayConfirm = false)
}
download.status = DownloadStatus.Paused;
}
+ downloadManager.SaveData();
}
- downloadManager.SaveData();
return true;
}
@@ -585,9 +585,36 @@ public override async void OnApplicationStarted(OnApplicationStartedEventArgs ar
public override void OnApplicationStopped(OnApplicationStoppedEventArgs args)
{
StopDownloadManager();
+ NileDownloadManagerView downloadManager = GetNileDownloadManager();
var settings = GetSettings();
if (settings != null)
{
+ if (settings.AutoRemoveCompletedDownloads != ClearCacheTime.Never)
+ {
+ var nextRemovingCompletedDownloadsTime = settings.NextRemovingCompletedDownloadsTime;
+ if (nextRemovingCompletedDownloadsTime != 0)
+ {
+ DateTimeOffset now = DateTime.UtcNow;
+ if (now.ToUnixTimeSeconds() >= nextRemovingCompletedDownloadsTime)
+ {
+ foreach (var downloadItem in downloadManager.downloadManagerData.downloads.ToList())
+ {
+ if (downloadItem.status == DownloadStatus.Completed)
+ {
+ downloadManager.downloadManagerData.downloads.Remove(downloadItem);
+ downloadManager.downloadsChanged = true;
+ }
+ }
+ settings.NextRemovingCompletedDownloadsTime = GetNextClearingTime(settings.AutoRemoveCompletedDownloads);
+ SavePluginSettings(settings);
+ }
+ }
+ else
+ {
+ settings.NextRemovingCompletedDownloadsTime = GetNextClearingTime(settings.AutoRemoveCompletedDownloads);
+ SavePluginSettings(settings);
+ }
+ }
if (settings.AutoClearCache != ClearCacheTime.Never)
{
var nextClearingTime = settings.NextClearingTime;
@@ -607,6 +634,7 @@ public override void OnApplicationStopped(OnApplicationStoppedEventArgs args)
SavePluginSettings(settings);
}
}
+ downloadManager.SaveData();
}
}
diff --git a/src/NileLibrarySettingsView.xaml b/src/NileLibrarySettingsView.xaml
index ba6ebc0..4748987 100644
--- a/src/NileLibrarySettingsView.xaml
+++ b/src/NileLibrarySettingsView.xaml
@@ -87,6 +87,7 @@
+
@@ -94,6 +95,8 @@
+
+
diff --git a/src/NileLibrarySettingsView.xaml.cs b/src/NileLibrarySettingsView.xaml.cs
index e19311d..5983569 100644
--- a/src/NileLibrarySettingsView.xaml.cs
+++ b/src/NileLibrarySettingsView.xaml.cs
@@ -124,6 +124,7 @@ private async void NileSettingsUC_Loaded(object sender, RoutedEventArgs e)
{ ClearCacheTime.Never, ResourceProvider.GetString(LOC.Nile3P_PlayniteSettingsPlaytimeImportModeNever) }
};
AutoClearCacheCBo.ItemsSource = autoClearOptions;
+ AutoRemoveCompletedDownloadsCBo.ItemsSource = autoClearOptions;
var updatePolicyOptions = new Dictionary
{
diff --git a/src/NileLibrarySettingsViewModel.cs b/src/NileLibrarySettingsViewModel.cs
index 4b09f6a..9a92f39 100644
--- a/src/NileLibrarySettingsViewModel.cs
+++ b/src/NileLibrarySettingsViewModel.cs
@@ -21,9 +21,11 @@ public class NileLibrarySettings
public DownloadCompleteAction DoActionAfterDownloadComplete { get; set; } = DownloadCompleteAction.Nothing;
public bool DisplayDownloadSpeedInBits { get; set; } = false;
public bool DisplayDownloadTaskFinishedNotifications { get; set; } = true;
+ public ClearCacheTime AutoRemoveCompletedDownloads { get; set; } = ClearCacheTime.Never;
public ClearCacheTime AutoClearCache { get; set; } = ClearCacheTime.Never;
public UpdatePolicy GamesUpdatePolicy { get; set; } = UpdatePolicy.Month;
public long NextClearingTime { get; set; } = 0;
+ public long NextRemovingCompletedDownloadsTime { get; set; } = 0;
public long NextGamesUpdateTime { get; set; } = 0;
public UpdatePolicy LauncherUpdatePolicy { get; set; } = UpdatePolicy.Month;
public long NextLauncherUpdateTime { get; set; } = 0;
@@ -89,6 +91,17 @@ public override void EndEdit()
Settings.NextClearingTime = 0;
}
}
+ if (EditingClone.AutoRemoveCompletedDownloads != Settings.AutoRemoveCompletedDownloads)
+ {
+ if (Settings.AutoRemoveCompletedDownloads != ClearCacheTime.Never)
+ {
+ Settings.NextRemovingCompletedDownloadsTime = NileLibrary.GetNextClearingTime(Settings.AutoRemoveCompletedDownloads);
+ }
+ else
+ {
+ Settings.NextRemovingCompletedDownloadsTime = 0;
+ }
+ }
if (EditingClone.GamesUpdatePolicy != Settings.GamesUpdatePolicy)
{
if (Settings.GamesUpdatePolicy != UpdatePolicy.Never)