Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove invalid zip files in NetKAN #3156

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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