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

fix(types): correct types for quota bytes #378

Merged
merged 1 commit into from
Aug 2, 2024
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
4 changes: 2 additions & 2 deletions source/tools/dav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export function parseSearch(result: DAVResult, searchArbiter: string, isDetailed
* @returns The value in bytes, or another indicator
*/
export function translateDiskSpace(value: string | number): DiskQuotaAvailable {
switch (value.toString()) {
switch (String(value)) {
case "-3":
return "unlimited";
case "-2":
Expand All @@ -246,6 +246,6 @@ export function translateDiskSpace(value: string | number): DiskQuotaAvailable {
// -1 is non-computed
return "unknown";
default:
return parseInt(value as string, 10);
return parseInt(String(value), 10);
}
}
3 changes: 2 additions & 1 deletion source/tools/quota.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export function parseQuota(result: DAVResult): DiskQuota | null {
} = responseItem;
return typeof quotaUsed !== "undefined" && typeof quotaAvail !== "undefined"
? {
used: parseInt(quotaUsed, 10),
// As it could be both a string or a number ensure we are working with a number
used: parseInt(String(quotaUsed), 10),
available: translateDiskSpace(quotaAvail)
}
: null;
Expand Down
4 changes: 2 additions & 2 deletions source/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export interface DAVResultResponseProps {
getetag?: string;
getcontentlength?: string;
getcontenttype?: string;
"quota-available-bytes"?: any;
"quota-used-bytes"?: string;
"quota-available-bytes"?: string | number;
"quota-used-bytes"?: string | number;

[additionalProp: string]: unknown;
}
Expand Down
Loading