mirror of https://github.com/veypi/OneAuth.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
715 B
TypeScript
23 lines
715 B
TypeScript
import { translateDiskSpace } from "./dav";
|
|
import { DAVResult, DiskQuota } from "../types";
|
|
|
|
export function parseQuota(result: DAVResult): DiskQuota | null {
|
|
try {
|
|
const [responseItem] = result.multistatus.response;
|
|
const {
|
|
propstat: {
|
|
prop: { "quota-used-bytes": quotaUsed, "quota-available-bytes": quotaAvail }
|
|
}
|
|
} = responseItem;
|
|
return typeof quotaUsed !== "undefined" && typeof quotaAvail !== "undefined"
|
|
? {
|
|
used: parseInt(quotaUsed, 10),
|
|
available: translateDiskSpace(quotaAvail)
|
|
}
|
|
: null;
|
|
} catch (err) {
|
|
/* ignore */
|
|
}
|
|
return null;
|
|
}
|