From 4fea195133cd539fb7b170ac1c023ef0724cf1ff Mon Sep 17 00:00:00 2001 From: dapplion Date: Fri, 19 Jul 2019 00:41:36 +0200 Subject: [PATCH] Remove file size limit in backup transfers fix test --- build/src/src/calls/backupGet.js | 46 ------------------------------- build/src/src/params.js | 3 +- build/src/test/backup.test.int.js | 3 +- 3 files changed, 3 insertions(+), 49 deletions(-) diff --git a/build/src/src/calls/backupGet.js b/build/src/src/calls/backupGet.js index 12223d67a..f603f17f1 100644 --- a/build/src/src/calls/backupGet.js +++ b/build/src/src/calls/backupGet.js @@ -1,4 +1,3 @@ -"use strict"; // 'datauri' requested to use 'use strict'; const params = require("params"); const path = require("path"); const logs = require("logs.js")(module); @@ -11,7 +10,6 @@ const dockerList = require("modules/dockerList"); const shell = require("utils/shell"); const validateBackupArray = require("utils/validateBackupArray"); -const maxSizeKb = 10e3; const tempTransferDir = params.TEMP_TRANSFER_DIR; /** @@ -65,19 +63,6 @@ const backupGet = async ({ id, backup }) => { if (!successfulBackups.length) throw Error(`Could not backup any item: ${lastError.stack}`); - /** - * Limit max file size until a DAppNode <-> client transport method is adopted - * $ du -s -k app/file.gz - * 12 app/file.gz - */ - const dirSizeKb = await getFileOrDirSize(backupDir); - if (dirSizeKb > 200e3) { - await shell(`rm -rf ${backupDir}`); - throw Error( - `Dir file transfers > ${maxSizeKb} KB are not allowed. Attempting ${dirSizeKb} KB` - ); - } - /** * Use the -C option to cd in the directory before doing the tar * Provide the list of directories / files to include to keep the file structure clean @@ -90,19 +75,6 @@ const backupGet = async ({ id, backup }) => { await shell(`tar -czf ${backupDirComp} -C ${backupDir} ${dirListToComp}`); await shell(`rm -rf ${backupDir}`); - /** - * Limit max file size until a DAppNode <-> client transport method is adopted - * $ du -s -k app/file.gz - * 12 app/file.gz - */ - const fileSizeKb = await getFileOrDirSize(backupDirComp); - if (fileSizeKb > 20e3) { - await shell(`rm -rf ${backupDirComp}`); - throw Error( - `File transfers > ${maxSizeKb} KB are not allowed. Attempting ${fileSizeKb} KB` - ); - } - const fileId = crypto.randomBytes(32).toString("hex"); await db.set(fileId, backupDirComp); @@ -127,22 +99,4 @@ const backupGet = async ({ id, backup }) => { } }; -// Utility - -/** - * Limit max file size until a DAppNode <-> client transport method is adopted - * $ du -s -k app/file.gz - * 12 app/file.gz - * @param {string} path "app/file.gz" - * @returns {string} size in KB "12" - */ -async function getFileOrDirSize(path) { - const output = await shell(`du -s -k ${path}`); - const sizeString = output - .trim() - .replace(/\t/g, " ") - .split(" ")[0]; - return parseInt(sizeString || "0"); -} - module.exports = backupGet; diff --git a/build/src/src/params.js b/build/src/src/params.js index 2b363f301..a2f7232a2 100644 --- a/build/src/src/params.js +++ b/build/src/src/params.js @@ -22,7 +22,8 @@ module.exports = { userActionLogsFilename: path.join(DNCORE_DIR, "userActionLogs.log"), // lowdb requires an absolute path DB_PATH: path.resolve(DNCORE_DIR, "dappmanagerdb.json"), - TEMP_TRANSFER_DIR: path.join(DNCORE_DIR, ".temp-transfer"), + // Temp transfer dir must not be in a volume + TEMP_TRANSFER_DIR: path.join("./", ".temp-transfer"), // Docker compose parameters DNS_SERVICE: "172.33.1.2", diff --git a/build/src/test/backup.test.int.js b/build/src/test/backup.test.int.js index 50a4bede3..a8eb6d51a 100644 --- a/build/src/test/backup.test.int.js +++ b/build/src/test/backup.test.int.js @@ -24,8 +24,7 @@ describe("Integration test for backup to and from:", function() { const dockerComposePath = "dnp_repo/test-backup.dnp.dappnode.eth/docker-compose.yml"; - const filePath = - "DNCORE/.temp-transfer/test-backup.dnp.dappnode.eth_backup.tar.xz"; + const filePath = ".temp-transfer/test-backup.dnp.dappnode.eth_backup.tar.xz"; /** * RESTORE => GET integral test