Skip to content

Commit

Permalink
Update deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
nakedmcse committed Mar 20, 2024
1 parent 02ec2a7 commit c08bc61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion waifuVault-csharp-api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageId>Waifuvault</PackageId>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
<Authors>Walker Aldridge (walker@waifuvault.moe)</Authors>
<Company>waifuvault.moe</Company>
<PackageTags>waifuvault;temp file hosting;waifu;vault</PackageTags>
Expand Down
15 changes: 12 additions & 3 deletions waifuvault.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ public static async Task<FileResponse> fileInfo(string token, bool formatted, Ca
var infoResponse = await client.GetAsync(url,ct != null ? ct.Value : cts.Token);
checkError(infoResponse,false);
var infoResponseData = await infoResponse.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<FileResponse>(infoResponseData) ?? new FileResponse();
var opts = new JsonSerializerOptions(){
NumberHandling = JsonNumberHandling.WriteAsString
};
return JsonSerializer.Deserialize<FileResponse>(infoResponseData,opts) ?? new FileResponse();
}

public static async Task<FileResponse> fileUpdate(string token, string? password = null, string? previousPassword = null, string? customExpiry = null, bool hideFilename = false, CancellationToken? ct = null) {
Expand All @@ -63,7 +66,10 @@ public static async Task<FileResponse> fileUpdate(string token, string? password
var infoResponse = await client.PatchAsync(url, content);
checkError(infoResponse,false);
var infoResponseData = await infoResponse.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<FileResponse>(infoResponseData) ?? new FileResponse();
var opts = new JsonSerializerOptions(){
NumberHandling = JsonNumberHandling.WriteAsString
};
return JsonSerializer.Deserialize<FileResponse>(infoResponseData,opts) ?? new FileResponse();
}

public static async Task<bool> deleteFile(string token, CancellationToken? ct = null) {
Expand Down Expand Up @@ -98,7 +104,10 @@ private static async Task<FileResponse> sendContent(string targetUrl, HttpConten
var fileResponse = await client.PutAsync(targetUrl, content, ct != null ? ct.Value : cts.Token);
checkError(fileResponse,false);
var fileResponseData = await fileResponse.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<FileResponse>(fileResponseData);
var opts = new JsonSerializerOptions(){
NumberHandling = JsonNumberHandling.WriteAsString
};
return JsonSerializer.Deserialize<FileResponse>(fileResponseData,opts);

Check warning on line 110 in waifuvault.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.
}

private static async void checkError(HttpResponseMessage? response, bool isDownload) {
Expand Down

0 comments on commit c08bc61

Please sign in to comment.