-
Notifications
You must be signed in to change notification settings - Fork 2
Add checksum in index, and improve cache logic #27
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
046fcbd
Add checksum in index, and improve cache logic
jetelain 5f30f07
Apply suggestions from code review
jetelain 47a3bd5
Fix typo
jetelain 4a39d12
More reliable http downloads
jetelain 3b63a68
Fix legacy typo
jetelain b84c5a2
Potential fix for pull request finding
jetelain 3255b46
Fixes
jetelain 8d06837
Sequential test for cache
jetelain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,64 @@ | ||
| { | ||
| "profiles": { | ||
| "Repack STRM": { | ||
| "Repack SRTM": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "repack -k -s E:\\Carto\\SRTMv3 -t c:\\temp\\SRTMv3 -m 10" | ||
| }, | ||
| "Repack AW3D30": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "repack -k -s E:\\Carto\\AW3D30 -t c:\\temp\\AW3D30 -m 10" | ||
| }, | ||
| "Index STRM": { | ||
|
|
||
| "Index AW3D30": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "index -p C:\\temp\\SRTMv3" | ||
| "commandLineArgs": "index -p D:\\dem\\AW3D30" | ||
| }, | ||
| "Index AW3D30": { | ||
| "Index SRTM15Plus": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "index -p D:\\dem\\SRTM15Plus" | ||
| }, | ||
| "Index SRTM1": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "index -p D:\\dem\\SRTM1" | ||
| }, | ||
|
|
||
| "Update Index AW3D30": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "update-index -p D:\\dem\\AW3D30" | ||
| }, | ||
| "Update Index SRTM15Plus": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "update-index -p D:\\dem\\SRTM15Plus" | ||
| }, | ||
| "Update Index SRTM1": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "update-index -p D:\\dem\\SRTM1" | ||
| }, | ||
|
|
||
| "Check AW3D30": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "check -v -p D:\\dem\\AW3D30" | ||
| }, | ||
| "Check SRTM15Plus": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "check -v -p D:\\dem\\SRTM15Plus" | ||
| }, | ||
| "Check SRTM1": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "check -v -p D:\\dem\\SRTM1" | ||
| }, | ||
|
|
||
| "Check CDN AW3D30": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "check -v -u https://cdn.dem.pmad.net/AW3D30/ -n 100" | ||
| }, | ||
| "Check CDN SRTM15Plus": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "check -v -u https://cdn.dem.pmad.net/SRTM15Plus/ -n 100" | ||
| }, | ||
| "Check CDN SRTM1": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "index -p C:\\temp\\AW3D30" | ||
| "commandLineArgs": "check -v -u https://cdn.dem.pmad.net/SRTM1/ -n 100" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| namespace Pmad.Cartography.Test | ||
| { | ||
| [CollectionDefinition("Sequential", DisableParallelization = true)] | ||
| public class SequentialCollectionDefinition { } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| using System; | ||
| using System.IO; | ||
| using System.Security.Cryptography; | ||
| using System.Threading.Tasks; | ||
| using Pmad.Cartography.Databases; | ||
| using Xunit; | ||
|
|
||
| namespace Pmad.Cartography.Test.Databases | ||
| { | ||
| public class DemFileSystemStorageTest | ||
| { | ||
| private static string CreateTempFile(byte[] content) | ||
| { | ||
| var path = Path.GetTempFileName(); | ||
| File.WriteAllBytes(path, content); | ||
| return path; | ||
| } | ||
|
|
||
| private static string ComputeExpectedHex(byte[] content) | ||
| { | ||
| return Convert.ToHexString(SHA256.HashData(content)).ToLowerInvariant(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task GetSha256Async_ShouldReturnCorrectHash_WhenFileExists() | ||
| { | ||
| // Arrange | ||
| var content = "hello dem"u8.ToArray(); | ||
| var file = CreateTempFile(content); | ||
| var basePath = Path.GetDirectoryName(file)!; | ||
| var fileName = Path.GetFileName(file); | ||
| var storage = new DemFileSystemStorage(basePath); | ||
|
|
||
| try | ||
| { | ||
| // Act | ||
| var hash = await storage.GetSha256Async(fileName); | ||
|
|
||
| // Assert | ||
| Assert.NotNull(hash); | ||
| Assert.Equal(ComputeExpectedHex(content), hash); | ||
| } | ||
| finally | ||
| { | ||
| File.Delete(file); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task GetSha256Async_ShouldReturnNull_WhenFileDoesNotExist() | ||
| { | ||
| // Arrange | ||
| var basePath = Path.GetTempPath(); | ||
| var storage = new DemFileSystemStorage(basePath); | ||
|
|
||
| // Act | ||
| var hash = await storage.GetSha256Async("nonexistent_file_that_does_not_exist.hgt.zst"); | ||
|
|
||
| // Assert | ||
| Assert.Null(hash); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task GetSha256Async_ShouldReturnLowercaseHex() | ||
| { | ||
| // Arrange | ||
| var content = "case check"u8.ToArray(); | ||
| var file = CreateTempFile(content); | ||
| var basePath = Path.GetDirectoryName(file)!; | ||
| var fileName = Path.GetFileName(file); | ||
| var storage = new DemFileSystemStorage(basePath); | ||
|
|
||
| try | ||
| { | ||
| // Act | ||
| var hash = await storage.GetSha256Async(fileName); | ||
|
|
||
| // Assert | ||
| Assert.NotNull(hash); | ||
| Assert.Equal(hash!.ToLowerInvariant(), hash); | ||
| } | ||
| finally | ||
| { | ||
| File.Delete(file); | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.