diff --git a/server/ftp-integration/taggedXML.js b/server/ftp-integration/taggedXML.js index 832811b38abe79e2f389f93fd4e58af955bad019..606513b1881b53068ebd863ed70f3320e80db0dc 100644 --- a/server/ftp-integration/taggedXML.js +++ b/server/ftp-integration/taggedXML.js @@ -9,9 +9,14 @@ const { execSync } = require('child_process') const uuidv4 = require('uuid/v4') const ftpTagger = config.get('ftp_tagger') + +const parentRootPath = '/home/yogmatee/projects/PLAY/chokidar/ftp_mock' + +/* const parentRootPath = `${process.env.HOME}/${config.get('ftp_directory')}/${ ftpTagger.username }` +*/ const rootPath = `${parentRootPath}/Done` diff --git a/server/utils/files.js b/server/utils/files.js index 423ba413f06e266d87e4e6fce853fdc040de96b7..59b844d18f83763bb6419101907165e5d19a78ef 100644 --- a/server/utils/files.js +++ b/server/utils/files.js @@ -101,7 +101,18 @@ module.exports.uploadFileToMinio = uploadFileToMinio module.exports.renameFile = function renameFile(path) { return new Promise((resolve, reject) => { - fs.rename(path, `${path}_${Date.now()}`, err => { + const datedFolder = dateFormat(new Date(), 'yyyy-mm-dd') + const dir_path = path.dirname(path) + const filename = path.basename(path) + + if (!fs.existsSync(`${dir_path}/DONE/${datedFolder}`)) { + fs.mkdirSync(`${dir_path}/DONE${datedFolder}`) + } + + const oldPath = path + const newPath = `${dir_path}/DONE/${datedFolder}/${filename}_${Date.now()}` + + fs.rename(oldPath, newPath, err => { if (err) reject(err) }) resolve(path)