264 lines
6.9 KiB
JSON
264 lines
6.9 KiB
JSON
{
|
|
"id": "6S41oPplwN1S9Lz0",
|
|
"name": "MAM Remote File Transfer",
|
|
"nodes": [
|
|
{
|
|
"parameters": {},
|
|
"id": "trigger-execute-workflow",
|
|
"name": "When Called by Another Workflow",
|
|
"type": "n8n-nodes-base.executeWorkflowTrigger",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
224,
|
|
304
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Extract directory path from destination path\nconst item = $input.first();\nconst destPath = item.json.dest_path || '';\n\n// Get everything before the last slash\nconst lastSlash = destPath.lastIndexOf('/');\nconst dirName = lastSlash >= 0 ? destPath.substring(0, lastSlash) : '';\n\nreturn [{\n json: {\n ...item.json,\n dir_name: dirName\n }\n}];"
|
|
},
|
|
"id": "code-extract-dirname",
|
|
"name": "Extract Directory Name",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
448,
|
|
304
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"authentication": "privateKey",
|
|
"command": "=mkdir -p '{{ $('Extract Directory Name').item.json.dir_name }}'"
|
|
},
|
|
"id": "ssh-mkdir",
|
|
"name": "Create Directory on seed-0",
|
|
"type": "n8n-nodes-base.ssh",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
672,
|
|
304
|
|
],
|
|
"credentials": {
|
|
"sshPrivateKey": {
|
|
"id": "vOzhicmbOwx1XDF8",
|
|
"name": "seed-0.local.ben.io"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"authentication": "privateKey",
|
|
"command": "=scp -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/.ssh/n8n.priv.key '{{ $('Extract Directory Name').item.json.source_path }}' 'root@{{ $('Extract Directory Name').item.json.dest_host }}:\"{{ $('Extract Directory Name').item.json.dest_path }}\"'"
|
|
},
|
|
"id": "ssh-scp",
|
|
"name": "SCP from seed-1 to seed-0",
|
|
"type": "n8n-nodes-base.ssh",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
880,
|
|
304
|
|
],
|
|
"credentials": {
|
|
"sshPrivateKey": {
|
|
"id": "foyggnWz8Sv0OO5w",
|
|
"name": "seed-1.dfw.ben.io"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"authentication": "privateKey",
|
|
"command": "=stat -c '%s' '{{ $('Extract Directory Name').item.json.dest_path }}'"
|
|
},
|
|
"id": "ssh-verify",
|
|
"name": "Verify File on seed-0",
|
|
"type": "n8n-nodes-base.ssh",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
1104,
|
|
304
|
|
],
|
|
"credentials": {
|
|
"sshPrivateKey": {
|
|
"id": "vOzhicmbOwx1XDF8",
|
|
"name": "seed-0.local.ben.io"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Verify file size matches expected\nconst item = $input.first(); // Output from ssh-verify (stdout)\nconst statOutput = item.json.stdout || item.json.output || '';\nconst actualSize = parseInt(statOutput.trim());\n\n// Get original context from earlier node\nconst originalItem = $('Extract Directory Name').item.json;\nconst expectedSize = originalItem.expected_size;\nconst destPath = originalItem.dest_path;\n\nconst verified = !isNaN(actualSize) && (!expectedSize || actualSize === expectedSize);\n\nreturn [{\n json: {\n ...originalItem, // Preserve full context\n status: verified ? 'success' : 'failed',\n final_path: destPath,\n verified: verified,\n actual_size: actualSize,\n expected_size: expectedSize,\n error: verified ? null : `Size mismatch: expected ${expectedSize}, got ${actualSize}`\n }\n}];"
|
|
},
|
|
"id": "code-check-size",
|
|
"name": "Check File Size",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
1328,
|
|
304
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"conditions": {
|
|
"options": {
|
|
"caseSensitive": true,
|
|
"leftValue": "",
|
|
"typeValidation": "strict"
|
|
},
|
|
"conditions": [
|
|
{
|
|
"id": "condition-1",
|
|
"leftValue": "={{ $json.verified }}",
|
|
"rightValue": true,
|
|
"operator": {
|
|
"type": "boolean",
|
|
"operation": "equals"
|
|
}
|
|
}
|
|
],
|
|
"combinator": "and"
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "if-verified",
|
|
"name": "File Verified?",
|
|
"type": "n8n-nodes-base.if",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
1552,
|
|
304
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"respondWith": "allIncomingItems",
|
|
"options": {}
|
|
},
|
|
"id": "respond-success",
|
|
"name": "Respond Success",
|
|
"type": "n8n-nodes-base.respondToWebhook",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
1984,
|
|
224
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"respondWith": "allIncomingItems",
|
|
"options": {}
|
|
},
|
|
"id": "respond-failed",
|
|
"name": "Respond Failed",
|
|
"type": "n8n-nodes-base.respondToWebhook",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
1984,
|
|
384
|
|
]
|
|
}
|
|
],
|
|
"connections": {
|
|
"When Called by Another Workflow": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Extract Directory Name",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Extract Directory Name": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Create Directory on seed-0",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Create Directory on seed-0": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "SCP from seed-1 to seed-0",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"SCP from seed-1 to seed-0": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Verify File on seed-0",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Verify File on seed-0": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Check File Size",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Check File Size": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "File Verified?",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"File Verified?": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Respond Failed",
|
|
"type": "main",
|
|
"index": 0
|
|
},
|
|
{
|
|
"node": "Respond Success",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
}
|
|
},
|
|
"settings": {
|
|
"saveExecutionProgress": true,
|
|
"saveManualExecutions": true,
|
|
"saveDataErrorExecution": "all",
|
|
"saveDataSuccessExecution": "all",
|
|
"executionOrder": "v1"
|
|
},
|
|
"triggerCount": 0,
|
|
"versionId": "0f762959-8423-4af4-92a9-82e006e0f90c",
|
|
"owner": {
|
|
"type": "personal",
|
|
"projectId": "FeLO36wNUAcn61Wj",
|
|
"projectName": "Ben W <admin@ben.io>",
|
|
"personalEmail": "admin@ben.io"
|
|
},
|
|
"parentFolderId": "6tDyZCwqELStb6Ik",
|
|
"isArchived": false
|
|
} |