mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-06-18 16:02:19 +02:00
feat(torrents): replace filename char
This commit is contained in:
2
config/env/torrents.js
vendored
2
config/env/torrents.js
vendored
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user