NeahNew/node_modules/webdav/dist/node/tools/quota.js
2025-05-03 14:17:46 +02:00

19 lines
693 B
JavaScript

import { translateDiskSpace } from "./dav.js";
export function parseQuota(result) {
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"
? {
// 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;
}
catch (err) {
/* ignore */
}
return null;
}