quilltap 3.0.0-dev.79 → 3.0.0-dev.81
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/lib/tar-extract.js +9 -0
- package/package.json +1 -1
package/lib/tar-extract.js
CHANGED
|
@@ -81,6 +81,10 @@ function extractTarBuffer(buffer, destDir) {
|
|
|
81
81
|
|
|
82
82
|
switch (type) {
|
|
83
83
|
case 'directory':
|
|
84
|
+
// If a file exists at this path, remove it so the directory can be created
|
|
85
|
+
if (fs.existsSync(fullPath) && !fs.statSync(fullPath).isDirectory()) {
|
|
86
|
+
fs.unlinkSync(fullPath);
|
|
87
|
+
}
|
|
84
88
|
fs.mkdirSync(fullPath, { recursive: true });
|
|
85
89
|
break;
|
|
86
90
|
|
|
@@ -89,6 +93,11 @@ function extractTarBuffer(buffer, destDir) {
|
|
|
89
93
|
const dir = path.dirname(fullPath);
|
|
90
94
|
fs.mkdirSync(dir, { recursive: true });
|
|
91
95
|
|
|
96
|
+
// If a directory exists at the file path, remove it first
|
|
97
|
+
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) {
|
|
98
|
+
fs.rmSync(fullPath, { recursive: true, force: true });
|
|
99
|
+
}
|
|
100
|
+
|
|
92
101
|
const fileData = buffer.subarray(offset, offset + size);
|
|
93
102
|
fs.writeFileSync(fullPath, fileData);
|
|
94
103
|
|