Skip to content

Commit

Permalink
Fix freeze on non CKAN files in cache folder
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Apr 27, 2019
1 parent 44d44ea commit 579da24
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Core/Net/NetFileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class NetFileCache : IDisposable
private Dictionary<string, string> 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));

/// <summary>
Expand Down Expand Up @@ -377,7 +378,10 @@ private List<FileInfo> 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();
}

/// <summary>
Expand Down

0 comments on commit 579da24

Please sign in to comment.