fixed filename length exceeding limit
This commit is contained in:
parent
dcd91ce8bf
commit
f04fb9209e
13
lib/util.js
13
lib/util.js
|
@ -128,10 +128,17 @@ function getPathByMetadata(source, output, metadata, callback) {
|
||||||
if (metadata.title) {
|
if (metadata.title) {
|
||||||
fileName += metadata.title.trim();
|
fileName += metadata.title.trim();
|
||||||
}
|
}
|
||||||
// append extension
|
// check length of filename, append extension and replace illegal chars
|
||||||
fileName += path.extname(source).trim();
|
const ext = path.extname(source).trim();
|
||||||
|
const max = (255 - ext.length);
|
||||||
|
fileName = fileName.trim();
|
||||||
|
if (fileName.length > max) {
|
||||||
|
const suffix = ' (...)';
|
||||||
|
fileName = fileName.substr(0, max - suffix.length).trim() + suffix;
|
||||||
|
}
|
||||||
|
fileName = replaceIllegalChars(fileName + ext);
|
||||||
// replace illegal chars, join directory and name
|
// replace illegal chars, join directory and name
|
||||||
callback(null, path.join(filePath, replaceIllegalChars(fileName)));
|
callback(null, path.join(filePath, fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill a string beginning from the front
|
// fill a string beginning from the front
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "badger-am",
|
"name": "badger-am",
|
||||||
"version": "0.7.0",
|
"version": "0.7.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "audio manager",
|
"description": "audio manager",
|
||||||
"author": "Daniel Sommer <daniel.sommer@velvettear.de>",
|
"author": "Daniel Sommer <daniel.sommer@velvettear.de>",
|
||||||
|
|
Loading…
Reference in a new issue