Fixed issues with extraction (migration from SharpCompress to Squid-Box.SevenZipSharp)

This commit is contained in:
Jeddunk 2021-01-04 15:43:27 +01:00
parent af8110e475
commit 2cfb7dc654
5 changed files with 47 additions and 36 deletions

View file

@ -45,17 +45,7 @@ namespace auto_creamapi.Services
string cacheString;
if (updateNeeded)
{
MyLogger.Log.Information("Getting content from API...");
var client = new HttpClient();
var httpCall = client.GetAsync(SteamUri);
var response = await httpCall.ConfigureAwait(false);
var readAsStringAsync = response.Content.ReadAsStringAsync();
var responseBody = await readAsStringAsync;
MyLogger.Log.Information("Got content from API successfully. Writing to file...");
await File.WriteAllTextAsync(CachePath, responseBody, Encoding.UTF8);
cacheString = responseBody;
MyLogger.Log.Information("Cache written to file successfully.");
cacheString = await UpdateCache().ConfigureAwait(false);
}
else
{
@ -63,12 +53,27 @@ namespace auto_creamapi.Services
// ReSharper disable once MethodHasAsyncOverload
cacheString = File.ReadAllText(CachePath);
}
var steamApps = JsonSerializer.Deserialize<SteamApps>(cacheString);
_cache = new HashSet<SteamApp>(steamApps.AppList.Apps);
MyLogger.Log.Information("Loaded cache into memory!");
}
private static async Task<string> UpdateCache()
{
MyLogger.Log.Information("Getting content from API...");
var client = new HttpClient();
var httpCall = client.GetAsync(SteamUri);
var response = await httpCall.ConfigureAwait(false);
var readAsStringAsync = response.Content.ReadAsStringAsync();
var responseBody = await readAsStringAsync;
MyLogger.Log.Information("Got content from API successfully. Writing to file...");
await File.WriteAllTextAsync(CachePath, responseBody, Encoding.UTF8);
var cacheString = responseBody;
MyLogger.Log.Information("Cache written to file successfully.");
return cacheString;
}
public IEnumerable<SteamApp> GetListOfAppsByName(string name)
{
var listOfAppsByName = _cache.Search(x => x.Name)