feat(torrents): replace filename char

This commit is contained in:
OldHawk
2017-08-03 14:04:25 +08:00
parent dfffcb8a09
commit f8aada9b00
2 changed files with 20 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ module.exports = {
url: 'http://chd.im:3000/announce',
comment: 'meanTorrent group',
announce_interval: 60 * 1000,
announce_prefix: '[CHD.im].',
announce_prefix: '{CHD.im}.',
admin: 'admin@chd.im',
base_url: 'http://chd.im:3000',
client_black_list_url: 'http://chd.im:3000/client_black_list',

View File

@@ -34,8 +34,25 @@ module.exports.subtitleFileFilter = function (req, file, callback) {
};
module.exports.createUploadFilename = function (req, file, cb) {
var regex = new RegExp(',', 'g');
var filename = file.originalname.replace(regex, ' ');
//var regex = new RegExp(',', 'g');
//var filename = file.originalname.replace(regex, ' ');
var RexStr = /\(|\)|\[|\]|\,/g;
var filename = file.originalname.replace(RexStr, function (MatchStr) {
switch (MatchStr) {
case '(':
return '<';
case ')':
return '>';
case '[':
return '{';
case ']':
return '}';
case ',':
return ' ';
default:
break;
}
});
if (fs.existsSync(config.uploads.torrent.file.temp + filename)) {
fs.unlinkSync(config.uploads.torrent.file.temp + filename);