diff --git a/core/ansi_term.js b/core/ansi_term.js index c9902c7d..7902d26c 100644 --- a/core/ansi_term.js +++ b/core/ansi_term.js @@ -473,4 +473,3 @@ function setEmulatedBaudRate(rate) { }[rate] || 0; return 0 === speed ? exports.emulationSpeed() : exports.emulationSpeed(1, speed); } - diff --git a/core/config.js b/core/config.js index ebd9bca5..f48ca84c 100644 --- a/core/config.js +++ b/core/config.js @@ -368,7 +368,7 @@ function getDefaultConfig() { desc : 'Gzip Archive', sig : '1f8b', offset : 0, - archiveHandler : '7Zip', + archiveHandler : 'TarGz', }, // :TODO: application/x-bzip 'application/x-bzip2' : { @@ -479,6 +479,22 @@ function getDefaultConfig() { cmd : 'unrar', args : [ 'e', '{archivePath}', '{extractPath}', '{fileList}' ], } + }, + + TarGz : { + decompress : { + cmd : 'tar', + args : [ '-xf', '{archivePath}', '-C', '{extractPath}', '--strip-components=1' ], + }, + list : { + cmd : 'tar', + args : [ '-tvf', '{archivePath}' ], + entryMatch : '^[drwx\\-]{10}\\s[A-Za-z0-9\\/]+\\s+([0-9]+)\\s[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}\\s[0-9]{2}\\:[0-9]{2}\\s([^\\r\\n]+)$', + }, + extract : { + cmd : 'tar', + args : [ '-xvf', '{archivePath}', '-C', '{extractPath}', '{fileList}' ], + } } }, }, diff --git a/core/database.js b/core/database.js index e3f8fc8a..e089ba19 100644 --- a/core/database.js +++ b/core/database.js @@ -71,9 +71,13 @@ function initializeDatabases(cb) { }); } +function enableForeignKeys(db) { + db.run('PRAGMA foreign_keys = ON;'); +} + const DB_INIT_TABLE = { system : (cb) => { - dbs.system.run('PRAGMA foreign_keys = ON;'); + enableForeignKeys(dbs.system); // Various stat/event logging - see stat_log.js dbs.system.run( @@ -110,7 +114,7 @@ const DB_INIT_TABLE = { }, user : (cb) => { - dbs.user.run('PRAGMA foreign_keys = ON;'); + enableForeignKeys(dbs.user); dbs.user.run( `CREATE TABLE IF NOT EXISTS user ( @@ -152,7 +156,7 @@ const DB_INIT_TABLE = { }, message : (cb) => { - dbs.message.run('PRAGMA foreign_keys = ON;'); + enableForeignKeys(dbs.message); dbs.message.run( `CREATE TABLE IF NOT EXISTS message ( @@ -260,7 +264,7 @@ const DB_INIT_TABLE = { }, file : (cb) => { - dbs.file.run('PRAGMA foreign_keys = ON;'); + enableForeignKeys(dbs.file); dbs.file.run( // :TODO: should any of this be unique -- file_sha256 unless dupes are allowed on the system @@ -363,6 +367,13 @@ const DB_INIT_TABLE = { expire_timestamp DATETIME NOT NULL );` ); +/* + dbs.file.run( + `CREATE TABLE IF NOT EXISTS user_file_last_upload_timestamp ( + user_id INTEGER PRIMARY KEY NOT NULL, + upload_timestamp DATETIME NOT NULL + );` + );*/ return cb(null); } diff --git a/core/file_area_web.js b/core/file_area_web.js index b4d93d81..bac85de7 100644 --- a/core/file_area_web.js +++ b/core/file_area_web.js @@ -284,7 +284,7 @@ class FileAreaWebAccess { resp.on('finish', () => { // transfer completed fully - this.updateDownloadStatsForUserId(servedItem.userId, stats.size); + this.updateDownloadStatsForUserIdAndSystemAndSystem(servedItem.userId, stats.size); }); const headers = { @@ -301,7 +301,7 @@ class FileAreaWebAccess { }); } - updateDownloadStatsForUserId(userId, dlBytes, cb) { + updateDownloadStatsForUserIdAndSystem(userId, dlBytes, cb) { async.waterfall( [ function fetchActiveUser(callback) { diff --git a/core/file_base_filter.js b/core/file_base_filter.js index 801ae47e..cd724c52 100644 --- a/core/file_base_filter.js +++ b/core/file_base_filter.js @@ -65,14 +65,14 @@ module.exports = class FileBaseFilters { let filtersProperty = this.client.user.properties.file_base_filters; let defaulted; if(!filtersProperty) { - filtersProperty = JSON.stringify(FileBaseFilters.getDefaultFilters()); + filtersProperty = JSON.stringify(FileBaseFilters.getBuiltInSystemFilters()); defaulted = true; } try { this.filters = JSON.parse(filtersProperty); } catch(e) { - this.filters = FileBaseFilters.getDefaultFilters(); // something bad happened; reset everything back to defaults :( + this.filters = FileBaseFilters.getBuiltInSystemFilters(); // something bad happened; reset everything back to defaults :( defaulted = true; this.client.log.error( { error : e.message, property : filtersProperty }, 'Failed parsing file base filters property' ); } @@ -107,20 +107,33 @@ module.exports = class FileBaseFilters { return false; } - static getDefaultFilters() { - const filters = {}; - - const uuid = uuidV4(); - filters[uuid] = { - name : 'Default', + static getBuiltInSystemFilters() { + const U_LATEST = '7458b09d-40ab-4f9b-a0d7-0cf866646329'; + + const filters = { + [ U_LATEST ] : { + name : 'Latest Additions', + areaTag : '', // all + terms : '', // * + tags : '', // * + order : 'descending', + sort : 'upload_timestamp', + uuid : U_LATEST, + system : true, + } + }; + /* + filters[U_LATEST] = { + name : 'Latest Additions', areaTag : '', // all terms : '', // * tags : '', // * order : 'descending', sort : 'upload_timestamp', - uuid : uuid, + uuid : U_LATEST, + system : true, }; - +*/ return filters; } diff --git a/core/mime_util.js b/core/mime_util.js index 0963d5e5..bdb88a53 100644 --- a/core/mime_util.js +++ b/core/mime_util.js @@ -15,7 +15,8 @@ function startup(cb) { // const ADDITIONAL_EXT_MIMETYPES = { arj : 'application/x-arj', - ans : 'text/x-ansi', + ans : 'text/x-ansi', + gz : 'application/gzip', // not in mime-types 2.1.15 :( }; _.forEach(ADDITIONAL_EXT_MIMETYPES, (mimeType, ext) => { @@ -23,6 +24,10 @@ function startup(cb) { if(!_.isString(mimeTypes.types[ext])) { mimeTypes[ext] = mimeType; } + + if(!mimeTypes.extensions[mimeType]) { + mimeTypes.extensions[mimeType] = [ ext ]; + } }); return cb(null); diff --git a/core/stat_log.js b/core/stat_log.js index 41c4ceb5..d6a53d28 100644 --- a/core/stat_log.js +++ b/core/stat_log.js @@ -92,6 +92,10 @@ class StatLog { getSystemStat(statName) { return this.systemStats[statName]; } + getSystemStatNum(statName) { + return parseInt(this.getSystemStat(statName)) || 0; + } + incrementSystemStat(statName, incrementBy, cb) { incrementBy = incrementBy || 1; diff --git a/core/string_util.js b/core/string_util.js index 05cdd0d7..250f6502 100644 --- a/core/string_util.js +++ b/core/string_util.js @@ -507,8 +507,8 @@ function createCleanAnsi(input, options, cb) { parser.parse(input); } - /* + const fs = require('graceful-fs'); let data = fs.readFileSync('/home/nuskooler/Downloads/art3.ans'); data = iconv.decode(data, 'cp437'); diff --git a/core/tic_file_info.js b/core/tic_file_info.js index 730155e6..d2216d66 100644 --- a/core/tic_file_info.js +++ b/core/tic_file_info.js @@ -17,6 +17,7 @@ const crypto = require('crypto'); // // Class to read and hold information from a TIC file // +// * FTS-5006.001 @ http://www.filegate.net/ftsc/FTS-5006.001 // * FSP-1039.001 @ http://ftsc.org/docs/old/fsp-1039.001 // * FSC-0087.001 @ http://ftsc.org/docs/fsc-0087.001 // diff --git a/mods/file_area_filter_edit.js b/mods/file_area_filter_edit.js index 00d13a2e..cb3322f9 100644 --- a/mods/file_area_filter_edit.js +++ b/mods/file_area_filter_edit.js @@ -61,7 +61,6 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule { this.menuMethods = { saveFilter : (formData, extraArgs, cb) => { return this.saveCurrentFilter(formData, cb); - }, prevFilter : (formData, extraArgs, cb) => { this.currentFilterIndex -= 1; @@ -93,7 +92,15 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule { return cb(null); }, deleteFilter : (formData, extraArgs, cb) => { - const filterUuid = this.filtersArray[this.currentFilterIndex].uuid; + const selectedFilter = this.filtersArray[this.currentFilterIndex]; + const filterUuid = selectedFilter.uuid; + + // cannot delete built-in/system filters + if(true === selectedFilter.system) { + this.showError('Cannot delete built in filters!'); + return cb(null); + } + this.filtersArray.splice(this.currentFilterIndex, 1); // remove selected entry // remove from stored properties @@ -143,6 +150,17 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule { }, }; } + + showError(errMsg) { + const errorView = this.viewControllers.editor.getView(MciViewIds.editor.error); + if(errorView) { + if(errMsg) { + errorView.setText(errMsg); + } else { + errorView.clearText(); + } + } + } mciReady(mciData, cb) { super.mciReady(mciData, err => { diff --git a/mods/file_area_list.js b/mods/file_area_list.js index 9dacc23d..81c041bf 100644 --- a/mods/file_area_list.js +++ b/mods/file_area_list.js @@ -212,8 +212,8 @@ exports.getModule = class FileAreaList extends MenuModule { const entryInfo = currEntry.entryInfo = { fileId : currEntry.fileId, areaTag : currEntry.areaTag, - areaName : area.name || 'N/A', - areaDesc : area.desc || 'N/A', + areaName : _.get(area, 'name') || 'N/A', + areaDesc : _.get(area, 'desc') || 'N/A', fileSha256 : currEntry.fileSha256, fileName : currEntry.fileName, desc : currEntry.desc || '',