From a615a8f2f1b99181b3386f3e5687069ec85359ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Climent?= Date: Sat, 1 Jun 2024 00:12:28 +0200 Subject: [PATCH] Set timeouts of a minute for general package manager tasks, to prevent infinite loads (related to #1954) --- .../Manager/PackageManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/PackageManager.cs b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/PackageManager.cs index ef5bb642d..c9e214deb 100644 --- a/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/PackageManager.cs +++ b/src/UniGetUI.PackageEngine.PackageManagerClasses/Manager/PackageManager.cs @@ -147,7 +147,7 @@ public async Task FindPackages(string query) if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet FindPackages was called"); return []; }; try { - Package[] packages = await FindPackages_UnSafe(query); + Package[] packages = await FindPackages_UnSafe(query).WaitAsync(TimeSpan.FromSeconds(60)); for (int i = 0; i < packages.Length; i++) { packages[i] = PackageFactory.GetAvailablePackageIfRepeated(packages[i]); @@ -174,8 +174,8 @@ public async Task GetAvailableUpdates() if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet GetAvailableUpdates was called"); return []; }; try { - await RefreshPackageIndexes(); - Package[] packages = await GetAvailableUpdates_UnSafe(); + await RefreshPackageIndexes().WaitAsync(TimeSpan.FromSeconds(60)); + Package[] packages = await GetAvailableUpdates_UnSafe().WaitAsync(TimeSpan.FromSeconds(60)); for (int i = 0; i < packages.Length; i++) packages[i] = PackageFactory.GetUpgradablePackageIfRepeated(packages[i]); Logger.Info($"Found {packages.Length} available updates from {Name}"); @@ -199,7 +199,7 @@ public async Task GetInstalledPackages() if (!IsReady()) { Logger.Warn($"Manager {Name} is disabled but yet GetInstalledPackages was called"); return []; }; try { - Package[] packages = await GetInstalledPackages_UnSafe(); + Package[] packages = await GetInstalledPackages_UnSafe().WaitAsync(TimeSpan.FromSeconds(60)); for (int i = 0; i < packages.Length; i++) packages[i] = PackageFactory.GetInstalledPackageIfRepeated(packages[i]); Logger.Info($"Found {packages.Length} installed packages from {Name}"); @@ -362,7 +362,7 @@ public virtual async Task GetSources() try { AssertSourceCompatibility("GetSources"); - var result = await SourceProvider.GetSources(); + var result = await SourceProvider.GetSources().WaitAsync(TimeSpan.FromSeconds(60)); Logger.Debug($"Loaded {result.Length} sources for manager {Name}"); return result; }