@xuda.io/drive_module 1.1.1492 → 1.1.1494
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/index.mjs +39 -26
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2223,33 +2223,39 @@ export const copy_file_to_another_bucket = async (source_region, target_region,
|
|
|
2223
2223
|
const get_folder_size = async (dir, drive_type, app_id, uid) => {
|
|
2224
2224
|
let totalSize = 0;
|
|
2225
2225
|
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
const
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
fs.promises
|
|
2242
|
-
.stat(childPath)
|
|
2243
|
-
.then((s) => {
|
|
2244
|
-
totalSize += s.size;
|
|
2245
|
-
})
|
|
2246
|
-
.catch(() => {}),
|
|
2247
|
-
);
|
|
2226
|
+
// Iterative walk (explicit stack) instead of deep async recursion. The old
|
|
2227
|
+
// `await calculateSizeFs(d)` self-recursion built an unbounded async call chain
|
|
2228
|
+
// on deeply-nested drives and blew the async stack (async_hooks promiseInit at
|
|
2229
|
+
// the readdir) inside get_folder_size. This keeps async depth O(1) regardless of
|
|
2230
|
+
// tree depth. Dirent.isDirectory() is false for symlinks, so symlinked dirs are
|
|
2231
|
+
// never followed here — no cycle risk.
|
|
2232
|
+
const calculateSizeFs = async (rootPath) => {
|
|
2233
|
+
const stack = [rootPath];
|
|
2234
|
+
while (stack.length) {
|
|
2235
|
+
const dirPath = stack.pop();
|
|
2236
|
+
let entries;
|
|
2237
|
+
try {
|
|
2238
|
+
entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
|
|
2239
|
+
} catch (err) {
|
|
2240
|
+
continue;
|
|
2248
2241
|
}
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2242
|
+
const file_stats = [];
|
|
2243
|
+
for (const entry of entries) {
|
|
2244
|
+
const childPath = path.join(dirPath, entry.name);
|
|
2245
|
+
if (entry.isDirectory()) {
|
|
2246
|
+
stack.push(childPath);
|
|
2247
|
+
} else if (entry.isFile()) {
|
|
2248
|
+
file_stats.push(
|
|
2249
|
+
fs.promises
|
|
2250
|
+
.stat(childPath)
|
|
2251
|
+
.then((s) => {
|
|
2252
|
+
totalSize += s.size;
|
|
2253
|
+
})
|
|
2254
|
+
.catch(() => {}),
|
|
2255
|
+
);
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
await Promise.all(file_stats);
|
|
2253
2259
|
}
|
|
2254
2260
|
};
|
|
2255
2261
|
|
|
@@ -2669,6 +2675,9 @@ export default {
|
|
|
2669
2675
|
|
|
2670
2676
|
doc.vite_build_res = vite_build_res;
|
|
2671
2677
|
doc.scriptData.dependencies = devDependencies;
|
|
2678
|
+
// build_error parity with the (former) blocking client flow: a clean build
|
|
2679
|
+
// clears any stale error so the editor stops flagging the doc.
|
|
2680
|
+
delete doc.build_error;
|
|
2672
2681
|
|
|
2673
2682
|
db_module.save_app_couch_doc(app_id, doc);
|
|
2674
2683
|
} catch (err) {
|
|
@@ -2680,6 +2689,10 @@ export default {
|
|
|
2680
2689
|
src_hash: js_src_hash(doc.scriptData?.value || ''),
|
|
2681
2690
|
data: err.message,
|
|
2682
2691
|
};
|
|
2692
|
+
// Stamp build_error on the doc itself (same contract as save_prog): the
|
|
2693
|
+
// studio save flow no longer blocks on the build, so editors learn of
|
|
2694
|
+
// failures from this self-saved rev replicating back.
|
|
2695
|
+
doc.build_error = { message: err?.message || 'Compilation error', ts: Date.now() };
|
|
2683
2696
|
console.error(doc._id, 'js compile failed:', String(err.message).slice(0, 300));
|
|
2684
2697
|
if (job_id || req.return_result) {
|
|
2685
2698
|
return doc.vite_build_res;
|