diff --git a/Knossos.NET/Classes/KnUtils.cs b/Knossos.NET/Classes/KnUtils.cs
index 5d1d1c07..a21d798d 100644
--- a/Knossos.NET/Classes/KnUtils.cs
+++ b/Knossos.NET/Classes/KnUtils.cs
@@ -85,6 +85,21 @@ static KnUtils()
public static bool IsAppImage => isAppImage;
public static string AppImagePath => appImagePath;
+ ///
+ /// Keeps a list of remote resources loaded to cache (or checked) during this session
+ /// So we don't constantly query these remote URLs for changes
+ ///
+ private static List remoteResourceLoadedToCache = new List();
+
+ ///
+ /// Clear list of remote url resources downloaded to cache (or checked) during this session
+ /// So they can be checked and redownloaded again without restarting if they are outdated.
+ ///
+ public static void ClearDownloadedRemoteResourceList()
+ {
+ remoteResourceLoadedToCache.Clear();
+ }
+
///
/// Full path to AppImage file
///
@@ -673,6 +688,7 @@ public static string GetCachePath()
var fileInCacheEtagPath = fileInCachePath + ".etag";
string? remoteEtag = null;
bool cacheFileExists = File.Exists(fileInCachePath);
+ bool cachedOrCheckedDuringThisSession = remoteResourceLoadedToCache.Contains(resourceURL);
Uri uri = new Uri(resourceURL);
bool isNebulaFile = Nebula.nebulaMirrors.Contains(uri.Host.ToLower());
cacheFileIsValid = cacheFileExists && new FileInfo(fileInCachePath).Length > 0 ? true : false;
@@ -681,9 +697,10 @@ public static string GetCachePath()
if (cacheFileIsValid && cacheFileExists)
{
bool cacheFileEtagExists = File.Exists(fileInCacheEtagPath);
- if (isNebulaFile)
+ if (isNebulaFile || cachedOrCheckedDuringThisSession)
{
//This is a nebula file, nebula files are stored by their checksum so they never update
+ //Or we already downloaded or checked this file during this session, lets not do it again
return fileInCachePath;
}
else if (cacheFileEtagExists)
@@ -694,6 +711,7 @@ public static string GetCachePath()
if (cachedEtag != null && cachedEtag == remoteEtag)
{
//cache is up to date
+ remoteResourceLoadedToCache.Add(resourceURL);
return fileInCachePath;
}
else
@@ -736,6 +754,7 @@ public static string GetCachePath()
Log.Add(Log.LogSeverity.Error, "KnUtils.GetRemoteResource()", ex);
}
}
+ remoteResourceLoadedToCache.Add(resourceURL);
return fileInCachePath;
}
catch (Exception ex)
diff --git a/Knossos.NET/Classes/Knossos.cs b/Knossos.NET/Classes/Knossos.cs
index a4ba8791..33da8912 100644
--- a/Knossos.NET/Classes/Knossos.cs
+++ b/Knossos.NET/Classes/Knossos.cs
@@ -765,6 +765,7 @@ public static void ResetBasePath()
TaskViewModel.Instance?.CancelAllRunningTasks();
Nebula.CancelOperations();
await Task.Delay(2000).ConfigureAwait(false);
+ KnUtils.ClearDownloadedRemoteResourceList();
LoadBasePath();
});
}