From edb9d32acc2db6cbb4fa72d13f2df50225cf27a7 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 12 Feb 2017 00:24:24 -0700 Subject: [PATCH] * Fix CRC32 meta * Properly store upload user info in meta @ upload --- core/file_base_area.js | 2 +- mods/upload.js | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/core/file_base_area.js b/core/file_base_area.js index 65365293..69e4d4cf 100644 --- a/core/file_base_area.js +++ b/core/file_base_area.js @@ -522,7 +522,7 @@ function scanFile(filePath, options, iterator, cb) { } else if('sha1' === hashName || 'md5' === hashName) { stepInfo[hashName] = fileEntry.meta[`file_${hashName}`] = hashes[hashName].digest('hex'); } else if('crc32' === hashName) { - stepInfo.crc32 = fileEntry.meta.crc32 = hashes.crc32.finalize().toString(16); + stepInfo.crc32 = fileEntry.meta.file_crc32 = hashes.crc32.finalize().toString(16); } return nextHash(null); diff --git a/mods/upload.js b/mods/upload.js index 7c9e0bbc..5faf0d76 100644 --- a/mods/upload.js +++ b/mods/upload.js @@ -314,9 +314,13 @@ exports.getModule = class UploadModule extends MenuModule { self.client.log.debug('Scanning upload(s)', { paths : this.recvFilePaths } ); + let currentFileNum = 0; + async.eachSeries(this.recvFilePaths, (filePath, nextFilePath) => { // :TODO: virus scanning/etc. should occur around here + currentFileNum += 1; + self.scanStatus = { indicatorPos : 0, }; @@ -327,11 +331,14 @@ exports.getModule = class UploadModule extends MenuModule { }; function handleScanStep(stepInfo, nextScanStep) { + stepInfo.totalFileNum = self.recvFilePaths.length; + stepInfo.currentFileNum = currentFileNum; + self.updateScanStepInfoViews(stepInfo); return nextScanStep(null); } - self.client.log.debug('Scanning file', { filePath : filePath } ); + self.client.log.debug('Scanning file', { filePath : filePath } ); scanFile(filePath, scanOpts, handleScanStep, (err, fileEntry, dupeEntries) => { if(err) { @@ -401,6 +408,9 @@ exports.getModule = class UploadModule extends MenuModule { prepDetailsForUpload(scanResults, cb) { async.eachSeries(scanResults.newEntries, (newEntry, nextEntry) => { + newEntry.meta.upload_by_username = this.client.user.username; + newEntry.meta.upload_by_user_id = this.client.user.userId; + this.displayFileDetailsPageForUploadEntry(newEntry, (err, newValues) => { if(err) { return nextEntry(err); @@ -474,15 +484,14 @@ exports.getModule = class UploadModule extends MenuModule { function populateDupeInfo(dupeListView, callback) { const dupeInfoFormat = self.menuConfig.config.dupeInfoFormat || '{fileName} @ {areaName}'; - dupes.forEach(dupe => { - const formatted = stringFormat(dupeInfoFormat, dupe); - if(dupeListView) { - // dupesInfoFormatX - dupeListView.addText(enigmaToAnsi(formatted)); - } else { - self.client.term.pipeWrite(`${formatted}\n`); - } - }); + if(dupeListView) { + dupeListView.setItems(dupes.map(dupe => stringFormat(dupeInfoFormat, dupe) ) ); + dupeListView.redraw(); + } else { + dupes.forEach(dupe => { + self.client.term.pipeWrite(`${stringFormat(dupeInfoFormat, dupe)}\n`); + }); + } return callback(null); },