nuxt-skew-protection 0.4.2 → 0.4.3
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/module.json +1 -1
- package/dist/module.mjs +16 -4
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -540,6 +540,7 @@ function createAssetManager(options) {
|
|
|
540
540
|
const assetTasks = [];
|
|
541
541
|
let skippedSamePath = 0;
|
|
542
542
|
let skippedSameFileId = 0;
|
|
543
|
+
const collectedPaths = /* @__PURE__ */ new Set();
|
|
543
544
|
for (const [versionId, versionData] of Object.entries(manifest.versions)) {
|
|
544
545
|
if (versionId === currentBuildId) {
|
|
545
546
|
continue;
|
|
@@ -554,6 +555,10 @@ function createAssetManager(options) {
|
|
|
554
555
|
skippedSameFileId++;
|
|
555
556
|
continue;
|
|
556
557
|
}
|
|
558
|
+
if (collectedPaths.has(asset)) {
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
collectedPaths.add(asset);
|
|
557
562
|
assetTasks.push({ versionId, asset, versionData });
|
|
558
563
|
}
|
|
559
564
|
}
|
|
@@ -565,12 +570,17 @@ function createAssetManager(options) {
|
|
|
565
570
|
const restoreStart = Date.now();
|
|
566
571
|
let totalBytes = 0;
|
|
567
572
|
let failedCount = 0;
|
|
573
|
+
const createdDirs = /* @__PURE__ */ new Set();
|
|
568
574
|
const batchResults = await processBatch(assetTasks, 25, async ({ versionId, asset, versionData }) => {
|
|
569
575
|
const storageKey = `${versionId}/${asset}`;
|
|
570
576
|
return await storage.getItemRaw(storageKey).then(async (assetData) => {
|
|
571
577
|
if (assetData) {
|
|
572
578
|
const targetPath = join$1(publicDir, asset);
|
|
573
|
-
|
|
579
|
+
const dir = dirname(targetPath);
|
|
580
|
+
if (!createdDirs.has(dir)) {
|
|
581
|
+
await promises.mkdir(dir, { recursive: true });
|
|
582
|
+
createdDirs.add(dir);
|
|
583
|
+
}
|
|
574
584
|
let dataToWrite;
|
|
575
585
|
if (Buffer.isBuffer(assetData)) {
|
|
576
586
|
dataToWrite = assetData;
|
|
@@ -579,7 +589,7 @@ function createAssetManager(options) {
|
|
|
579
589
|
} else {
|
|
580
590
|
dataToWrite = Buffer.from(assetData);
|
|
581
591
|
}
|
|
582
|
-
await promises.writeFile(targetPath, dataToWrite);
|
|
592
|
+
await promises.writeFile(targetPath, dataToWrite, { flag: "wx" });
|
|
583
593
|
totalBytes += dataToWrite.byteLength;
|
|
584
594
|
const versionTimestamp = new Date(versionData.timestamp).getTime();
|
|
585
595
|
const ageMs = now - versionTimestamp;
|
|
@@ -605,8 +615,10 @@ function createAssetManager(options) {
|
|
|
605
615
|
}
|
|
606
616
|
return null;
|
|
607
617
|
}).catch((error) => {
|
|
608
|
-
|
|
609
|
-
|
|
618
|
+
if (error.code !== "EEXIST") {
|
|
619
|
+
failedCount++;
|
|
620
|
+
logger.debug(`Failed to restore asset ${asset} from version ${versionId}: ${error}`);
|
|
621
|
+
}
|
|
610
622
|
return null;
|
|
611
623
|
});
|
|
612
624
|
});
|