Fix tag-adding bugs of the importer (#427)

This commit is contained in:
Cornelicorn 2020-06-21 14:48:13 +02:00 committed by GitHub
parent 7ad0dd43e2
commit 041b2dfcc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -393,6 +393,12 @@ const importFile = (file, remove, resolve) => {
// Intersect tags from filename with existing tags on server // Intersect tags from filename with existing tags on server
let foundtags = []; let foundtags = [];
for (let j of taglist) { for (let j of taglist) {
// If the tag is last in the filename it could include a file extension and would not be recognized
if (j.includes('.') && !tagsarray.hasOwnProperty(j) && !foundtags.includes(tagsarray[j])) {
while (j.includes('.') && !tagsarray.hasOwnProperty(j)) {
j = j.replace(/\.[^.]*$/,'');
}
}
if (tagsarray.hasOwnProperty(j) && !foundtags.includes(tagsarray[j])) { if (tagsarray.hasOwnProperty(j) && !foundtags.includes(tagsarray[j])) {
foundtags.push(tagsarray[j]); foundtags.push(tagsarray[j]);
filename = filename.split('#'+j).join(''); filename = filename.split('#'+j).join('');
@ -413,7 +419,8 @@ const importFile = (file, remove, resolve) => {
else { else {
data = { data = {
title: prefs.importer.addtags ? filename : file.replace(/^.*[\\\/]/, '').substring(0, 100), title: prefs.importer.addtags ? filename : file.replace(/^.*[\\\/]/, '').substring(0, 100),
language: prefs.importer.lang || 'eng' language: prefs.importer.lang || 'eng',
tags: prefs.importer.tag === '' ? undefined : prefs.importer.tag
} }
} }
// Create document // Create document