-
Notifications
You must be signed in to change notification settings - Fork 70
Add support to download only the updated ranges using Etags, keeping … #74
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
base: main
Are you sure you want to change the base?
Conversation
…resiliency and updating to match current version This is based almost entirely off of eduardo010174's work. I just added the resiliency support in from the newer version.
Don't have problem for me. Other solution it's generate on server side on file with indexed Etag's of all files. @CNScott |
No problem from me. Thank you! We really needed this feature! |
{ | ||
try | ||
{ | ||
string json = JsonSerializer.Serialize(_etag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the content, why not serialize like this, to make the output cleaner?
string json = JsonSerializer.Serialize(_etag, s_jsonOptions);
Using this:
private static JsonSerializerOptions s_jsonOptions = new() { Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
var request = new HttpRequestMessage(HttpMethod.Get, requestUri); | ||
if (!string.IsNullOrEmpty(_etag[i])) | ||
{ | ||
request.Headers.Add("If-None-Match", _etag[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the built in string constants?
request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(_etag[i]));
@@ -250,7 +325,12 @@ private async Task<Stream> GetPwnedPasswordsRangeFromWeb(int i, bool fetchNtlm) | |||
break; | |||
} | |||
|
|||
return content; | |||
if (data_updated && response.Headers.TryGetValues("Etag", out IEnumerable<string>? new_etag)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be clearer?
if (data_updated)
{
_etag[i] = response.Headers.ETag?.Tag ?? "";
}
…resiliency and updating to match current version
This is based almost entirely off of eduardo010174's work. I just added the resiliency support in from the newer version.