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.
OneAuth/oaweb/src/oaer/libs/webdav/tools/quota.ts

23 lines
715 B
TypeScript

3 years ago
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;
}