braidfs 0.0.51 → 0.0.52
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.js +15 -15
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -589,22 +589,22 @@ async function proxy_url(url) {
|
|
|
589
589
|
}
|
|
590
590
|
|
|
591
591
|
async function ensure_path(path) {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
592
|
+
var parts = path.split('/').slice(1)
|
|
593
|
+
for (var i = 1; i <= parts.length; i++) {
|
|
594
|
+
var partial = '/' + parts.slice(0, i).join('/')
|
|
595
|
+
await within_file_lock(partial, async () => {
|
|
596
|
+
try {
|
|
597
|
+
let stat = await require("fs").promises.stat(partial)
|
|
598
|
+
if (stat.isDirectory()) return // good
|
|
599
|
+
|
|
600
|
+
let temp = `${temp_folder}/${Math.random().toString(36).slice(2)}`
|
|
601
|
+
await require('fs').promises.rename(partial, temp)
|
|
602
|
+
await require("fs").promises.mkdir(partial)
|
|
603
|
+
await require('fs').promises.rename(temp, partial + '/index')
|
|
604
|
+
} catch (e) {
|
|
605
|
+
await require("fs").promises.mkdir(partial)
|
|
606
606
|
}
|
|
607
|
-
}
|
|
607
|
+
})
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
610
|
|