Skip to content

Commit

Permalink
Merge #3156 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
2 parents 808ec8a + 41e4652 commit 0195a05
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.

- [Build] Move to PackageReferences (#3125 by: Olympic1; reviewed: HebaruSan)
- [Build] Cache build tools (#3127 by: HebaruSan; reviewed: DasSkelett)
- [Netkan] Remove invalid zip files in NetKAN (#3156 by DasSkelett; reviewed: HebaruSan)

## v1.28.0 (Dyson)

Expand Down
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 0195a05

Please sign in to comment.