@muhgholy/next-drive 4.17.1 → 4.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -321,19 +321,19 @@ var getDriveConfig = () => {
321
321
  if (!g.config) throw new Error("Drive configuration not initialized");
322
322
  return g.config;
323
323
  };
324
- var getDriveInformation = async (req) => {
324
+ var getDriveInformation = async (input) => {
325
325
  const config = getDriveConfig();
326
326
  if (config.mode === "ROOT") {
327
327
  if (!config.information) {
328
328
  return {
329
- key: null,
329
+ key: input.method === "KEY" ? input.key : null,
330
330
  storage: { quotaInBytes: Number.MAX_SAFE_INTEGER }
331
331
  // Unlimited quota in ROOT mode
332
332
  };
333
333
  }
334
- return config.information(req);
334
+ return config.information(input);
335
335
  }
336
- return config.information(req);
336
+ return config.information(input);
337
337
  };
338
338
  var StorageAccountSchema = new mongoose.Schema(
339
339
  {
@@ -1620,7 +1620,8 @@ var driveUpload = async (source, key, options) => {
1620
1620
  }
1621
1621
  const isRootMode = config.mode === "ROOT";
1622
1622
  if (!options.enforce && !isRootMode) {
1623
- const quota = await provider.getQuota(key, accountId, Number.MAX_SAFE_INTEGER);
1623
+ const information = await getDriveInformation({ method: "KEY", key });
1624
+ const quota = await provider.getQuota(key, accountId, information.storage.quotaInBytes);
1624
1625
  if (quota.usedInBytes + fileSize > quota.quotaInBytes) {
1625
1626
  throw new Error("Storage quota exceeded");
1626
1627
  }
@@ -1894,7 +1895,7 @@ var driveAPIHandler = async (req, res) => {
1894
1895
  }
1895
1896
  try {
1896
1897
  const mode = config.mode || "NORMAL";
1897
- const information = await getDriveInformation(req);
1898
+ const information = await getDriveInformation({ method: "REQUEST", req });
1898
1899
  const { key: owner } = information;
1899
1900
  const STORAGE_PATH = config.storage.path;
1900
1901
  const isRootMode = mode === "ROOT";
@@ -2425,5 +2426,5 @@ exports.driveReadFile = driveReadFile;
2425
2426
  exports.driveUpload = driveUpload;
2426
2427
  exports.getDriveConfig = getDriveConfig;
2427
2428
  exports.getDriveInformation = getDriveInformation;
2428
- //# sourceMappingURL=chunk-ZYDFFRK3.cjs.map
2429
- //# sourceMappingURL=chunk-ZYDFFRK3.cjs.map
2429
+ //# sourceMappingURL=chunk-TBBX3C6E.cjs.map
2430
+ //# sourceMappingURL=chunk-TBBX3C6E.cjs.map