From 579da242213c7a5331620fc3934e7443beb9c056 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sat, 27 Apr 2019 19:11:55 +0000 Subject: [PATCH] Fix freeze on non CKAN files in cache folder --- Core/Net/NetFileCache.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/Net/NetFileCache.cs b/Core/Net/NetFileCache.cs index de9bb203a5..d84a0d1da3 100644 --- a/Core/Net/NetFileCache.cs +++ b/Core/Net/NetFileCache.cs @@ -30,6 +30,7 @@ public class NetFileCache : IDisposable private Dictionary cachedFiles; private string cachePath; private KSPManager manager; + private static readonly Regex cacheFileRegex = new Regex("^[0-9A-F]{8}-", RegexOptions.Compiled); private static readonly ILog log = LogManager.GetLogger(typeof (NetFileCache)); /// @@ -377,7 +378,10 @@ private List allFiles() DirectoryInfo legDir = new DirectoryInfo(legacyDir); files = files.Union(legDir.EnumerateFiles()); } - return files.ToList(); + return files + // Require 8 digit hex prefix followed by dash; any else was not put there by CKAN + .Where(fi => cacheFileRegex.IsMatch(fi.Name)) + .ToList(); } ///