@muhgholy/next-drive 4.16.0 → 4.17.1
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.
- package/dist/{chunk-PFIAZK57.js → chunk-QUBHH4G4.js} +28 -18
- package/dist/chunk-QUBHH4G4.js.map +1 -0
- package/dist/{chunk-HNLXZW5G.cjs → chunk-ZYDFFRK3.cjs} +28 -18
- package/dist/chunk-ZYDFFRK3.cjs.map +1 -0
- package/dist/server/config.d.ts.map +1 -1
- package/dist/server/controllers/drive.d.ts.map +1 -1
- package/dist/server/express.cjs +11 -11
- package/dist/server/express.js +2 -2
- package/dist/server/index.cjs +13 -13
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-HNLXZW5G.cjs.map +0 -1
- package/dist/chunk-PFIAZK57.js.map +0 -1
|
@@ -251,21 +251,30 @@ var runMigrations = async (storagePath) => {
|
|
|
251
251
|
};
|
|
252
252
|
|
|
253
253
|
// src/server/config.ts
|
|
254
|
-
var
|
|
255
|
-
var
|
|
256
|
-
|
|
254
|
+
var GLOBAL_KEY = "__nextDrive";
|
|
255
|
+
var getGlobal = () => {
|
|
256
|
+
if (!globalThis[GLOBAL_KEY]) {
|
|
257
|
+
globalThis[GLOBAL_KEY] = {
|
|
258
|
+
config: null,
|
|
259
|
+
migrationPromise: null,
|
|
260
|
+
initialized: false
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return globalThis[GLOBAL_KEY];
|
|
264
|
+
};
|
|
257
265
|
var driveConfiguration = async (config) => {
|
|
266
|
+
const g = getGlobal();
|
|
258
267
|
if (mongoose__default.default.connection.readyState !== 1) {
|
|
259
268
|
throw new Error("Database not connected. Please connect to Mongoose before initializing next-drive.");
|
|
260
269
|
}
|
|
261
|
-
if (
|
|
262
|
-
if (migrationPromise) await migrationPromise;
|
|
263
|
-
return
|
|
270
|
+
if (g.initialized && g.config) {
|
|
271
|
+
if (g.migrationPromise) await g.migrationPromise;
|
|
272
|
+
return g.config;
|
|
264
273
|
}
|
|
265
274
|
const resolvedPath = config.storage?.path || path__default.default.join(os3__default.default.tmpdir(), "next-drive-data");
|
|
266
275
|
const mode = config.mode || "NORMAL";
|
|
267
276
|
if (mode === "ROOT") {
|
|
268
|
-
|
|
277
|
+
g.config = {
|
|
269
278
|
...config,
|
|
270
279
|
mode: "ROOT",
|
|
271
280
|
storage: {
|
|
@@ -284,7 +293,7 @@ var driveConfiguration = async (config) => {
|
|
|
284
293
|
if (!config.information) {
|
|
285
294
|
throw new Error("information callback is required in NORMAL mode");
|
|
286
295
|
}
|
|
287
|
-
|
|
296
|
+
g.config = {
|
|
288
297
|
...config,
|
|
289
298
|
mode: "NORMAL",
|
|
290
299
|
storage: {
|
|
@@ -300,16 +309,17 @@ var driveConfiguration = async (config) => {
|
|
|
300
309
|
information: config.information
|
|
301
310
|
};
|
|
302
311
|
}
|
|
303
|
-
|
|
304
|
-
if (!migrationPromise) {
|
|
305
|
-
migrationPromise = runMigrations(resolvedPath);
|
|
312
|
+
g.initialized = true;
|
|
313
|
+
if (!g.migrationPromise) {
|
|
314
|
+
g.migrationPromise = runMigrations(resolvedPath);
|
|
306
315
|
}
|
|
307
|
-
await migrationPromise;
|
|
308
|
-
return
|
|
316
|
+
await g.migrationPromise;
|
|
317
|
+
return g.config;
|
|
309
318
|
};
|
|
310
319
|
var getDriveConfig = () => {
|
|
311
|
-
|
|
312
|
-
|
|
320
|
+
const g = getGlobal();
|
|
321
|
+
if (!g.config) throw new Error("Drive configuration not initialized");
|
|
322
|
+
return g.config;
|
|
313
323
|
};
|
|
314
324
|
var getDriveInformation = async (req) => {
|
|
315
325
|
const config = getDriveConfig();
|
|
@@ -1610,7 +1620,7 @@ var driveUpload = async (source, key, options) => {
|
|
|
1610
1620
|
}
|
|
1611
1621
|
const isRootMode = config.mode === "ROOT";
|
|
1612
1622
|
if (!options.enforce && !isRootMode) {
|
|
1613
|
-
const quota = await provider.getQuota(key, accountId,
|
|
1623
|
+
const quota = await provider.getQuota(key, accountId, Number.MAX_SAFE_INTEGER);
|
|
1614
1624
|
if (quota.usedInBytes + fileSize > quota.quotaInBytes) {
|
|
1615
1625
|
throw new Error("Storage quota exceeded");
|
|
1616
1626
|
}
|
|
@@ -2415,5 +2425,5 @@ exports.driveReadFile = driveReadFile;
|
|
|
2415
2425
|
exports.driveUpload = driveUpload;
|
|
2416
2426
|
exports.getDriveConfig = getDriveConfig;
|
|
2417
2427
|
exports.getDriveInformation = getDriveInformation;
|
|
2418
|
-
//# sourceMappingURL=chunk-
|
|
2419
|
-
//# sourceMappingURL=chunk-
|
|
2428
|
+
//# sourceMappingURL=chunk-ZYDFFRK3.cjs.map
|
|
2429
|
+
//# sourceMappingURL=chunk-ZYDFFRK3.cjs.map
|