Updates to upload check, docs

This commit is contained in:
Bryan Ashby 2017-02-09 22:03:21 -07:00
parent f9e91987ac
commit 2e10fdfdf5
5 changed files with 39 additions and 20 deletions

View File

@ -45,6 +45,9 @@ nvm install 6
nvm alias default 6
```
### ES6
Newly written code will use ES6 and a lot of code has started the migration process. Of note is the `MenuModule` class. If you have created a mod that inherits from `MenuModule`, you will need to upgrade your class to ES6.
## Manual Database Upgrade
A few upgrades need to be made to your SQLite databases:

View File

@ -121,23 +121,21 @@ function shutdownSystem() {
},
function stopListeningServers(callback) {
return require('./listening_server.js').shutdown( () => {
// :TODO: log err
return callback(null); // ignore err
});
},
function stopEventScheduler(callback) {
if(initServices.eventScheduler) {
return initServices.eventScheduler.shutdown( () => {
callback(null); // ignore err
return callback(null); // ignore err
});
} else {
return callback(null);
}
},
function stopFileAreaWeb(callback) {
require('./file_area_web.js').startup(err => {
// :TODO: Log me if err
return callback(null);
require('./file_area_web.js').startup( () => {
return callback(null); // ignore err
});
},
function stopMsgNetwork(callback) {

View File

@ -566,6 +566,12 @@ function scanFile(filePath, options, iterator, cb) {
getExistingFileEntriesBySha256(fileEntry.fileSha256, (err, dupeEntries) => {
return callback(err, dupeEntries);
});
},
function finished(dupeEntries, callback) {
stepInfo.step = 'finished';
callIter( () => {
return callback(null, dupeEntries);
});
}
],
(err, dupeEntries) => {

View File

@ -401,8 +401,9 @@ exports.MenuModule = class MenuModule extends PluginModule {
let textView;
let customMciId = startId;
const config = this.menuConfig.config;
const endId = options.endId || 99; // we'll fail to get a view before 99
while( (textView = this.viewControllers[formName].getView(customMciId)) ) {
while(customMciId <= endId && (textView = this.viewControllers[formName].getView(customMciId)) ) {
const key = `${formName}InfoFormat${customMciId}`; // e.g. "mainInfoFormat10"
const format = config[key];

View File

@ -49,7 +49,7 @@ const MciViewIds = {
calcHashIndicator : 1,
archiveListIndicator : 2,
descFileIndicator : 3,
logStep : 4,
customRangeStart : 10, // 10+ = customs
},
@ -218,9 +218,12 @@ exports.getModule = class UploadModule extends MenuModule {
const fmtObj = Object.assign( {}, stepInfo);
let stepIndicatorFmt = '';
let logStepFmt;
const indicatorStates = this.menuConfig.config.indicatorStates || [ '|', '/', '-', '\\' ];
const indicatorFinished = this.menuConfig.config.indicatorFinished || '√';
const fmtConfig = this.menuConfig.config;
const indicatorStates = fmtConfig.indicatorStates || [ '|', '/', '-', '\\' ];
const indicatorFinished = fmtConfig.indicatorFinished || '√';
const indicator = { };
const self = this;
@ -241,43 +244,47 @@ exports.getModule = class UploadModule extends MenuModule {
switch(stepInfo.step) {
case 'start' :
stepIndicatorFmt = this.menuConfig.config.scanningStartFormat || 'Scanning {fileName}';
logStepFmt = stepIndicatorFmt = fmtConfig.scanningStartFormat || 'Scanning {fileName}';
break;
case 'hash_update' :
stepIndicatorFmt = this.menuConfig.calcHashFormat || 'Calculating hash/checksums: {calcHashPercent}%';
stepIndicatorFmt = fmtConfig.calcHashFormat || 'Calculating hash/checksums: {calcHashPercent}%';
updateIndicator(MciViewIds.processing.calcHashIndicator);
break;
case 'hash_finish' :
stepIndicatorFmt = this.menuConfig.calcHashCompleteFormat || 'Finished calculating hash/checksums';
stepIndicatorFmt = fmtConfig.calcHashCompleteFormat || 'Finished calculating hash/checksums';
updateIndicator(MciViewIds.processing.calcHashIndicator, true);
break;
case 'archive_list_start' :
stepIndicatorFmt = this.menuConfig.extractArchiveListFormat || 'Extracting archive list';
stepIndicatorFmt = fmtConfig.extractArchiveListFormat || 'Extracting archive list';
updateIndicator(MciViewIds.processing.archiveListIndicator);
break;
case 'archive_list_finish' :
fmtObj.archivedFileCount = stepInfo.archiveEntries.length;
stepIndicatorFmt = this.menuConfig.extractArchiveListFinishFormat || 'Archive list extracted ({archivedFileCount} files)';
stepIndicatorFmt = fmtConfig.extractArchiveListFinishFormat || 'Archive list extracted ({archivedFileCount} files)';
updateIndicator(MciViewIds.processing.archiveListIndicator, true);
break;
case 'archive_list_failed' :
stepIndicatorFmt = this.menuConfig.extractArchiveListFailedFormat || 'Archive list extraction failed';
stepIndicatorFmt = fmtConfig.extractArchiveListFailedFormat || 'Archive list extraction failed';
break;
case 'desc_files_start' :
stepIndicatorFmt = this.menuConfig.processingDescFilesFormat || 'Processing description files';
stepIndicatorFmt = fmtConfig.processingDescFilesFormat || 'Processing description files';
updateIndicator(MciViewIds.processing.descFileIndicator);
break;
case 'desc_files_finish' :
stepIndicatorFmt = this.menuConfig.processingDescFilesFinishFormat || 'Finished processing description files';
stepIndicatorFmt = fmtConfig.processingDescFilesFinishFormat || 'Finished processing description files';
updateIndicator(MciViewIds.processing.descFileIndicator, true);
break;
case 'finished' :
logStepFmt = stepIndicatorFmt = fmtConfig.scanningStartFormat || 'Finished';
break;
}
fmtObj.stepIndicatorText = stringFormat(stepIndicatorFmt, fmtObj);
@ -288,6 +295,10 @@ exports.getModule = class UploadModule extends MenuModule {
if(indicator.mci && indicator.text) {
this.setViewText('processing', indicator.mci, indicator.text);
}
if(logStepFmt) {
this.setViewText('processing', MciViewIds.processing.logStep, stringFormat(logStepFmt, fmtObj), { appendMultiLine : true } );
}
} else {
this.client.term.pipeWrite(fmtObj.stepIndicatorText);
}
@ -649,7 +660,7 @@ exports.getModule = class UploadModule extends MenuModule {
const tagsView = self.viewControllers.fileDetails.getView(MciViewIds.fileDetails.tags);
const yearView = self.viewControllers.fileDetails.getView(MciViewIds.fileDetails.estYear);
self.updateCustomViewTextsWithFilter('fileDetails', MciViewIds.fileDetails.customRangeStart, fileEntry);
self.updateCustomViewTextsWithFilter('fileDetails', MciViewIds.fileDetails.customRangeStart, fileEntry );
tagsView.setText( Array.from(fileEntry.hashTags).join(',') ); // :TODO: optional 'hashTagsSep' like file list/browse
yearView.setText(fileEntry.meta.est_release_year || '');