sliftutils 1.4.73 → 1.4.74
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/package.json +1 -1
- package/storage/remoteFileServer.ts +21 -12
package/package.json
CHANGED
|
@@ -601,23 +601,32 @@ function getCompactor(baseDir: string, name: string): BulkDatabaseBase<{ key: st
|
|
|
601
601
|
export async function autocompactBulkDatabases(root: string): Promise<void> {
|
|
602
602
|
// Collections live under <baseDir>/bulkDatabases2/<name>/. The app may nest its data under a "data"
|
|
603
603
|
// subfolder (see getFileStorageNested2's heuristic), so look in both <root> and <root>/data.
|
|
604
|
+
const collections: { baseDir: string; name: string }[] = [];
|
|
604
605
|
for (const baseDir of [root, path.join(root, "data")]) {
|
|
605
|
-
let names: string[];
|
|
606
606
|
try {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
} catch { continue; } // no bulkDatabases2 here
|
|
610
|
-
for (const name of names) {
|
|
611
|
-
const start = Date.now();
|
|
612
|
-
console.log(` [autocompact] ${name}: starting merge`);
|
|
613
|
-
try {
|
|
614
|
-
await getCompactor(baseDir, name).tryMergeNow();
|
|
615
|
-
console.log(` [autocompact] ${name}: done (${Date.now() - start}ms)`);
|
|
616
|
-
} catch (e) {
|
|
617
|
-
console.warn(` [autocompact] ${name}: failed after ${Date.now() - start}ms - ${(e as Error).message}`);
|
|
607
|
+
for (const d of fs.readdirSync(path.join(baseDir, BULK_ROOT_FOLDER), { withFileTypes: true })) {
|
|
608
|
+
if (d.isDirectory()) collections.push({ baseDir, name: d.name });
|
|
618
609
|
}
|
|
610
|
+
} catch { continue; } // no bulkDatabases2 here
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const total = collections.length;
|
|
614
|
+
if (!total) return;
|
|
615
|
+
const passStart = Date.now();
|
|
616
|
+
console.log(` [autocompact] iterating over ${total} collection(s)`);
|
|
617
|
+
for (let i = 0; i < total; i++) {
|
|
618
|
+
const { baseDir, name } = collections[i];
|
|
619
|
+
const at = `${i + 1} / ${total}`;
|
|
620
|
+
const start = Date.now();
|
|
621
|
+
console.log(` [autocompact] ${at} ${name}: starting merge`);
|
|
622
|
+
try {
|
|
623
|
+
await getCompactor(baseDir, name).tryMergeNow();
|
|
624
|
+
console.log(` [autocompact] ${at} ${name}: done (${Date.now() - start}ms)`);
|
|
625
|
+
} catch (e) {
|
|
626
|
+
console.warn(` [autocompact] ${at} ${name}: failed after ${Date.now() - start}ms - ${(e as Error).message}`);
|
|
619
627
|
}
|
|
620
628
|
}
|
|
629
|
+
console.log(` [autocompact] done all ${total} collection(s) (${Date.now() - passStart}ms)`);
|
|
621
630
|
}
|
|
622
631
|
|
|
623
632
|
// CLI entry (invoked by bin/filehoster.js or `yarn filehoster <folder>`). Starts the server, logs the
|