New and moved files Upsert themselves in FileManager.FilePathCache

This commit is contained in:
Robert McRackan 2021-10-08 11:47:54 -04:00
parent 18cca53968
commit d0b78cc501
11 changed files with 149 additions and 144 deletions

View file

@ -56,9 +56,15 @@ namespace FileManager
}
public static void Upsert(string id, FileType type, string path)
{
if (!File.Exists(path))
throw new FileNotFoundException("Cannot add path to cache. File not found");
{
if (!File.Exists(path))
{
// file not found can happen after rapid move
System.Threading.Thread.Sleep(100);
if (!File.Exists(path))
throw new FileNotFoundException($"Cannot add path to cache. File not found. Id={id} FileType={type}", path);
}
var entry = cache.SingleOrDefault(i => i.Id == id && i.FileType == type);