@beltar/n8n-nodes-extract-archive 1.1.0 → 1.2.0
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.
|
@@ -2,7 +2,6 @@ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription
|
|
|
2
2
|
export declare class ExtractArchive implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
4
|
private detectArchiveType;
|
|
5
|
-
private checkToolAvailable;
|
|
6
5
|
private extractZip;
|
|
7
6
|
private extractRar;
|
|
8
7
|
private getAllFiles;
|
|
@@ -32,15 +32,17 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.ExtractArchive = void 0;
|
|
37
40
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
38
|
-
const child_process_1 = require("child_process");
|
|
39
41
|
const fs = __importStar(require("fs"));
|
|
40
42
|
const crypto = __importStar(require("crypto"));
|
|
41
43
|
const path = __importStar(require("path"));
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
+
const promises_1 = require("stream/promises");
|
|
45
|
+
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
44
46
|
class ExtractArchive {
|
|
45
47
|
constructor() {
|
|
46
48
|
this.description = {
|
|
@@ -245,26 +247,9 @@ class ExtractArchive {
|
|
|
245
247
|
// Default to zip
|
|
246
248
|
return 'zip';
|
|
247
249
|
}
|
|
248
|
-
checkToolAvailable(tool) {
|
|
249
|
-
try {
|
|
250
|
-
(0, child_process_1.execSync)(`which ${tool}`, { encoding: 'utf-8', stdio: 'pipe' });
|
|
251
|
-
return true;
|
|
252
|
-
}
|
|
253
|
-
catch {
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
250
|
async extractZip(archivePath, outputDir, password) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
const args = ['-o', '-q']; // Overwrite, quiet
|
|
262
|
-
if (password) {
|
|
263
|
-
args.push('-P', password);
|
|
264
|
-
}
|
|
265
|
-
args.push(archivePath, '-d', outputDir);
|
|
266
|
-
const command = `unzip ${args.map(a => `"${a}"`).join(' ')}`;
|
|
267
|
-
await execAsync(command);
|
|
251
|
+
const zip = new adm_zip_1.default(archivePath);
|
|
252
|
+
zip.extractAllTo(outputDir, true, undefined, password || undefined);
|
|
268
253
|
}
|
|
269
254
|
async extractRar(archivePath, outputDir, password) {
|
|
270
255
|
const { createExtractorFromFile } = await Promise.resolve().then(() => __importStar(require('node-unrar-js')));
|
|
@@ -446,7 +431,8 @@ class ExtractArchive {
|
|
|
446
431
|
? path.join(targetDir, relPath)
|
|
447
432
|
: path.join(targetDir, fileName);
|
|
448
433
|
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
449
|
-
|
|
434
|
+
// Use streams instead of copyFileSync to avoid EPERM on network shares (CIFS/SMB)
|
|
435
|
+
await (0, promises_1.pipeline)(fs.createReadStream(srcPath), fs.createWriteStream(destPath));
|
|
450
436
|
}
|
|
451
437
|
}
|
|
452
438
|
if (outputMode === 'single') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beltar/n8n-nodes-extract-archive",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "n8n node to extract ZIP and RAR archive files. Supports binary data or file path input.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
]
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@types/adm-zip": "^0.5.7",
|
|
43
44
|
"@types/node": "^20.10.0",
|
|
44
45
|
"n8n-workflow": "^1.20.0",
|
|
45
46
|
"shx": "^0.4.0",
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"node": ">=18.0.0"
|
|
53
54
|
},
|
|
54
55
|
"dependencies": {
|
|
56
|
+
"adm-zip": "^0.5.16",
|
|
55
57
|
"node-unrar-js": "^2.0.2"
|
|
56
58
|
}
|
|
57
59
|
}
|