mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 16:47:22 +01:00
fix existing broken filecache.csv with dupes on startup
This commit is contained in:
parent
fb983712c4
commit
f15b8f6bbd
1 changed files with 15 additions and 0 deletions
|
|
@ -77,6 +77,7 @@ public sealed class FileCacheManager : IDisposable
|
||||||
_logger.LogWarning("Could not load entries from {path}, continuing with empty file cache", _csvPath);
|
_logger.LogWarning("Could not load entries from {path}, continuing with empty file cache", _csvPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dictionary<string, bool> processedFiles = new(StringComparer.OrdinalIgnoreCase);
|
||||||
foreach (var entry in entries)
|
foreach (var entry in entries)
|
||||||
{
|
{
|
||||||
var splittedEntry = entry.Split(CsvSplit, StringSplitOptions.None);
|
var splittedEntry = entry.Split(CsvSplit, StringSplitOptions.None);
|
||||||
|
|
@ -86,6 +87,15 @@ public sealed class FileCacheManager : IDisposable
|
||||||
if (hash.Length != 40) throw new InvalidOperationException("Expected Hash length of 40, received " + hash.Length);
|
if (hash.Length != 40) throw new InvalidOperationException("Expected Hash length of 40, received " + hash.Length);
|
||||||
var path = splittedEntry[1];
|
var path = splittedEntry[1];
|
||||||
var time = splittedEntry[2];
|
var time = splittedEntry[2];
|
||||||
|
|
||||||
|
if (processedFiles.ContainsKey(path))
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Already processed {file}, ignoring", path);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
processedFiles.Add(path, true);
|
||||||
|
|
||||||
long size = -1;
|
long size = -1;
|
||||||
long compressed = -1;
|
long compressed = -1;
|
||||||
if (splittedEntry.Length > 3)
|
if (splittedEntry.Length > 3)
|
||||||
|
|
@ -106,6 +116,11 @@ public sealed class FileCacheManager : IDisposable
|
||||||
_logger.LogWarning(ex, "Failed to initialize entry {entry}, ignoring", entry);
|
_logger.LogWarning(ex, "Failed to initialize entry {entry}, ignoring", entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (processedFiles.Count != entries.Length)
|
||||||
|
{
|
||||||
|
WriteOutFullCsv();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue