mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 19:47:21 +01:00
more refactoring, rework FileCacheManager
This commit is contained in:
parent
2dcd02d170
commit
6ee159f716
11 changed files with 172 additions and 95 deletions
|
|
@ -87,7 +87,7 @@ namespace MareSynchronos.WebAPI
|
|||
public void Dispose()
|
||||
{
|
||||
Logger.Debug("Disposing " + nameof(ApiController));
|
||||
|
||||
|
||||
_cts?.Cancel();
|
||||
_ = DisposeHubConnections();
|
||||
}
|
||||
|
|
@ -124,19 +124,9 @@ namespace MareSynchronos.WebAPI
|
|||
var hash = file.Hash;
|
||||
var data = await DownloadFile(hash);
|
||||
var extractedFile = LZ4Codec.Unwrap(data);
|
||||
var ext = file.GamePaths.First().Split(".", StringSplitOptions.None).Last();
|
||||
var ext = file.GamePaths.First().Split(".").Last();
|
||||
var filePath = Path.Combine(_pluginConfiguration.CacheFolder, file.Hash + "." + ext);
|
||||
await File.WriteAllBytesAsync(filePath, extractedFile);
|
||||
await using (var db = new FileCacheContext())
|
||||
{
|
||||
db.Add(new FileCache
|
||||
{
|
||||
Filepath = filePath.ToLower(),
|
||||
Hash = file.Hash,
|
||||
LastModifiedDate = DateTime.Now.Ticks.ToString(),
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
Logger.Debug("File downloaded to " + filePath);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue