* Don't allow 'system' filters to be deleted
* Code cleanup * Static UUID for "default/system" filters
This commit is contained in:
parent
fb9ecbfb93
commit
d230a2f58b
|
@ -473,4 +473,3 @@ function setEmulatedBaudRate(rate) {
|
||||||
}[rate] || 0;
|
}[rate] || 0;
|
||||||
return 0 === speed ? exports.emulationSpeed() : exports.emulationSpeed(1, speed);
|
return 0 === speed ? exports.emulationSpeed() : exports.emulationSpeed(1, speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -368,7 +368,7 @@ function getDefaultConfig() {
|
||||||
desc : 'Gzip Archive',
|
desc : 'Gzip Archive',
|
||||||
sig : '1f8b',
|
sig : '1f8b',
|
||||||
offset : 0,
|
offset : 0,
|
||||||
archiveHandler : '7Zip',
|
archiveHandler : 'TarGz',
|
||||||
},
|
},
|
||||||
// :TODO: application/x-bzip
|
// :TODO: application/x-bzip
|
||||||
'application/x-bzip2' : {
|
'application/x-bzip2' : {
|
||||||
|
@ -479,6 +479,22 @@ function getDefaultConfig() {
|
||||||
cmd : 'unrar',
|
cmd : 'unrar',
|
||||||
args : [ 'e', '{archivePath}', '{extractPath}', '{fileList}' ],
|
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}' ],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -71,9 +71,13 @@ function initializeDatabases(cb) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function enableForeignKeys(db) {
|
||||||
|
db.run('PRAGMA foreign_keys = ON;');
|
||||||
|
}
|
||||||
|
|
||||||
const DB_INIT_TABLE = {
|
const DB_INIT_TABLE = {
|
||||||
system : (cb) => {
|
system : (cb) => {
|
||||||
dbs.system.run('PRAGMA foreign_keys = ON;');
|
enableForeignKeys(dbs.system);
|
||||||
|
|
||||||
// Various stat/event logging - see stat_log.js
|
// Various stat/event logging - see stat_log.js
|
||||||
dbs.system.run(
|
dbs.system.run(
|
||||||
|
@ -110,7 +114,7 @@ const DB_INIT_TABLE = {
|
||||||
},
|
},
|
||||||
|
|
||||||
user : (cb) => {
|
user : (cb) => {
|
||||||
dbs.user.run('PRAGMA foreign_keys = ON;');
|
enableForeignKeys(dbs.user);
|
||||||
|
|
||||||
dbs.user.run(
|
dbs.user.run(
|
||||||
`CREATE TABLE IF NOT EXISTS user (
|
`CREATE TABLE IF NOT EXISTS user (
|
||||||
|
@ -152,7 +156,7 @@ const DB_INIT_TABLE = {
|
||||||
},
|
},
|
||||||
|
|
||||||
message : (cb) => {
|
message : (cb) => {
|
||||||
dbs.message.run('PRAGMA foreign_keys = ON;');
|
enableForeignKeys(dbs.message);
|
||||||
|
|
||||||
dbs.message.run(
|
dbs.message.run(
|
||||||
`CREATE TABLE IF NOT EXISTS message (
|
`CREATE TABLE IF NOT EXISTS message (
|
||||||
|
@ -260,7 +264,7 @@ const DB_INIT_TABLE = {
|
||||||
},
|
},
|
||||||
|
|
||||||
file : (cb) => {
|
file : (cb) => {
|
||||||
dbs.file.run('PRAGMA foreign_keys = ON;');
|
enableForeignKeys(dbs.file);
|
||||||
|
|
||||||
dbs.file.run(
|
dbs.file.run(
|
||||||
// :TODO: should any of this be unique -- file_sha256 unless dupes are allowed on the system
|
// :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
|
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);
|
return cb(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ class FileAreaWebAccess {
|
||||||
|
|
||||||
resp.on('finish', () => {
|
resp.on('finish', () => {
|
||||||
// transfer completed fully
|
// transfer completed fully
|
||||||
this.updateDownloadStatsForUserId(servedItem.userId, stats.size);
|
this.updateDownloadStatsForUserIdAndSystemAndSystem(servedItem.userId, stats.size);
|
||||||
});
|
});
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
|
@ -301,7 +301,7 @@ class FileAreaWebAccess {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDownloadStatsForUserId(userId, dlBytes, cb) {
|
updateDownloadStatsForUserIdAndSystem(userId, dlBytes, cb) {
|
||||||
async.waterfall(
|
async.waterfall(
|
||||||
[
|
[
|
||||||
function fetchActiveUser(callback) {
|
function fetchActiveUser(callback) {
|
||||||
|
|
|
@ -65,14 +65,14 @@ module.exports = class FileBaseFilters {
|
||||||
let filtersProperty = this.client.user.properties.file_base_filters;
|
let filtersProperty = this.client.user.properties.file_base_filters;
|
||||||
let defaulted;
|
let defaulted;
|
||||||
if(!filtersProperty) {
|
if(!filtersProperty) {
|
||||||
filtersProperty = JSON.stringify(FileBaseFilters.getDefaultFilters());
|
filtersProperty = JSON.stringify(FileBaseFilters.getBuiltInSystemFilters());
|
||||||
defaulted = true;
|
defaulted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.filters = JSON.parse(filtersProperty);
|
this.filters = JSON.parse(filtersProperty);
|
||||||
} catch(e) {
|
} 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;
|
defaulted = true;
|
||||||
this.client.log.error( { error : e.message, property : filtersProperty }, 'Failed parsing file base filters property' );
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDefaultFilters() {
|
static getBuiltInSystemFilters() {
|
||||||
const filters = {};
|
const U_LATEST = '7458b09d-40ab-4f9b-a0d7-0cf866646329';
|
||||||
|
|
||||||
const uuid = uuidV4();
|
const filters = {
|
||||||
filters[uuid] = {
|
[ U_LATEST ] : {
|
||||||
name : 'Default',
|
name : 'Latest Additions',
|
||||||
areaTag : '', // all
|
areaTag : '', // all
|
||||||
terms : '', // *
|
terms : '', // *
|
||||||
tags : '', // *
|
tags : '', // *
|
||||||
order : 'descending',
|
order : 'descending',
|
||||||
sort : 'upload_timestamp',
|
sort : 'upload_timestamp',
|
||||||
uuid : uuid,
|
uuid : U_LATEST,
|
||||||
|
system : true,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
|
filters[U_LATEST] = {
|
||||||
|
name : 'Latest Additions',
|
||||||
|
areaTag : '', // all
|
||||||
|
terms : '', // *
|
||||||
|
tags : '', // *
|
||||||
|
order : 'descending',
|
||||||
|
sort : 'upload_timestamp',
|
||||||
|
uuid : U_LATEST,
|
||||||
|
system : true,
|
||||||
|
};
|
||||||
|
*/
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ function startup(cb) {
|
||||||
const ADDITIONAL_EXT_MIMETYPES = {
|
const ADDITIONAL_EXT_MIMETYPES = {
|
||||||
arj : 'application/x-arj',
|
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) => {
|
_.forEach(ADDITIONAL_EXT_MIMETYPES, (mimeType, ext) => {
|
||||||
|
@ -23,6 +24,10 @@ function startup(cb) {
|
||||||
if(!_.isString(mimeTypes.types[ext])) {
|
if(!_.isString(mimeTypes.types[ext])) {
|
||||||
mimeTypes[ext] = mimeType;
|
mimeTypes[ext] = mimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!mimeTypes.extensions[mimeType]) {
|
||||||
|
mimeTypes.extensions[mimeType] = [ ext ];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return cb(null);
|
return cb(null);
|
||||||
|
|
|
@ -92,6 +92,10 @@ class StatLog {
|
||||||
|
|
||||||
getSystemStat(statName) { return this.systemStats[statName]; }
|
getSystemStat(statName) { return this.systemStats[statName]; }
|
||||||
|
|
||||||
|
getSystemStatNum(statName) {
|
||||||
|
return parseInt(this.getSystemStat(statName)) || 0;
|
||||||
|
}
|
||||||
|
|
||||||
incrementSystemStat(statName, incrementBy, cb) {
|
incrementSystemStat(statName, incrementBy, cb) {
|
||||||
incrementBy = incrementBy || 1;
|
incrementBy = incrementBy || 1;
|
||||||
|
|
||||||
|
|
|
@ -507,8 +507,8 @@ function createCleanAnsi(input, options, cb) {
|
||||||
|
|
||||||
parser.parse(input);
|
parser.parse(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
const fs = require('graceful-fs');
|
const fs = require('graceful-fs');
|
||||||
let data = fs.readFileSync('/home/nuskooler/Downloads/art3.ans');
|
let data = fs.readFileSync('/home/nuskooler/Downloads/art3.ans');
|
||||||
data = iconv.decode(data, 'cp437');
|
data = iconv.decode(data, 'cp437');
|
||||||
|
|
|
@ -17,6 +17,7 @@ const crypto = require('crypto');
|
||||||
//
|
//
|
||||||
// Class to read and hold information from a TIC file
|
// 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
|
// * FSP-1039.001 @ http://ftsc.org/docs/old/fsp-1039.001
|
||||||
// * FSC-0087.001 @ http://ftsc.org/docs/fsc-0087.001
|
// * FSC-0087.001 @ http://ftsc.org/docs/fsc-0087.001
|
||||||
//
|
//
|
||||||
|
|
|
@ -61,7 +61,6 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule {
|
||||||
this.menuMethods = {
|
this.menuMethods = {
|
||||||
saveFilter : (formData, extraArgs, cb) => {
|
saveFilter : (formData, extraArgs, cb) => {
|
||||||
return this.saveCurrentFilter(formData, cb);
|
return this.saveCurrentFilter(formData, cb);
|
||||||
|
|
||||||
},
|
},
|
||||||
prevFilter : (formData, extraArgs, cb) => {
|
prevFilter : (formData, extraArgs, cb) => {
|
||||||
this.currentFilterIndex -= 1;
|
this.currentFilterIndex -= 1;
|
||||||
|
@ -93,7 +92,15 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule {
|
||||||
return cb(null);
|
return cb(null);
|
||||||
},
|
},
|
||||||
deleteFilter : (formData, extraArgs, cb) => {
|
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
|
this.filtersArray.splice(this.currentFilterIndex, 1); // remove selected entry
|
||||||
|
|
||||||
// remove from stored properties
|
// remove from stored properties
|
||||||
|
@ -144,6 +151,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) {
|
mciReady(mciData, cb) {
|
||||||
super.mciReady(mciData, err => {
|
super.mciReady(mciData, err => {
|
||||||
if(err) {
|
if(err) {
|
||||||
|
|
|
@ -212,8 +212,8 @@ exports.getModule = class FileAreaList extends MenuModule {
|
||||||
const entryInfo = currEntry.entryInfo = {
|
const entryInfo = currEntry.entryInfo = {
|
||||||
fileId : currEntry.fileId,
|
fileId : currEntry.fileId,
|
||||||
areaTag : currEntry.areaTag,
|
areaTag : currEntry.areaTag,
|
||||||
areaName : area.name || 'N/A',
|
areaName : _.get(area, 'name') || 'N/A',
|
||||||
areaDesc : area.desc || 'N/A',
|
areaDesc : _.get(area, 'desc') || 'N/A',
|
||||||
fileSha256 : currEntry.fileSha256,
|
fileSha256 : currEntry.fileSha256,
|
||||||
fileName : currEntry.fileName,
|
fileName : currEntry.fileName,
|
||||||
desc : currEntry.desc || '',
|
desc : currEntry.desc || '',
|
||||||
|
|
Loading…
Reference in New Issue