Only append path if not empty

This commit is contained in:
Jonas Kvinge 2020-10-21 21:32:12 +02:00
parent ffd2e2188a
commit 3a0d59e66f
1 changed files with 9 additions and 1 deletions

View File

@ -115,7 +115,15 @@ QString OrganizeFormat::GetFilenameForSong(const Song &song, QString extension)
if (QFileInfo(filename).completeBaseName().isEmpty()) {
// Avoid having empty filenames, or filenames with extension only: in this case, keep the original filename.
// We remove the extension from "filename" if it exists, as song.basefilename() also contains the extension.
filename = QFileInfo(filename).path() + "/" + song.basefilename();
QString path = QFileInfo(filename).path();
filename.clear();
if (!path.isEmpty()) {
filename.append(path);
if (path.right(1) != '/' && path.right(1) != '\\') {
filename.append('/');
}
}
filename.append(song.basefilename());
}
if (remove_problematic_) filename = filename.remove(kProblematicCharacters);