Skip to content

Commit

Permalink
Remove invalid zip files in NetKAN
Browse files Browse the repository at this point in the history
  • Loading branch information
DasSkelett committed Sep 23, 2020
1 parent 808ec8a commit 41e4652
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Netkan/Services/CachingHttpService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using log4net;
using CKAN.NetKAN.Model;

Expand Down Expand Up @@ -88,7 +89,8 @@ private string DownloadPackage(Uri url, string identifier, DateTime? updated, Ur
string invalidReason;
if (!NetFileCache.ZipValid(downloadedFile, out invalidReason))
{
log.Debug($"{downloadedFile} is not a valid ZIP file: {invalidReason}");
log.Debug($"{url} is not a valid ZIP file: {invalidReason}");
File.Delete(downloadedFile);
throw new Kraken($"{url} is not a valid ZIP file: {invalidReason}");
}
break;
Expand All @@ -114,7 +116,7 @@ public string DownloadText(Uri url, string authToken, string mimeType = null)
{
return TryGetCached(url, () => Net.DownloadText(url, authToken, mimeType));
}

private string TryGetCached(Uri url, Func<string> uncached)
{
if (_stringCache.TryGetValue(url, out StringCacheEntry entry))
Expand Down Expand Up @@ -153,5 +155,5 @@ public class StringCacheEntry
public string Value;
public DateTime Timestamp;
}

}
2 changes: 1 addition & 1 deletion Netkan/Transformers/NetkanTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ IValidator validator
new VersionEditTransformer(),
new ForcedVTransformer(),
new EpochTransformer(),
// This is the "default" VersionedOverrideTransformer for compatability with overrides that don't
// This is the "default" VersionedOverrideTransformer for compatibility with overrides that don't
// specify a before or after property.
new VersionedOverrideTransformer(before: new string[] { null }, after: new string[] { null }),
new DownloadAttributeTransformer(http, fileService),
Expand Down

0 comments on commit 41e4652

Please sign in to comment.