TSCORE.metaFileList.forEach(function(element, index) { if (element.name.indexOf(name) >= 0) { if (newFileName) { var pathOld = TSCORE.Utils.dirName(oldFileName); var pathNew = TSCORE.Utils.dirName(newFileName); var path = TSCORE.currentPath; if (pathNew.lastIndexOf(TSCORE.dirSeparator) === 0) { pathOld += TSCORE.dirSeparator; } if (pathOld != pathNew) { path = pathNew; } var newName = TSCORE.Utils.baseName(newFileName) + "." + element.name.split('.').pop(); var newFilePath = path + TSCORE.dirSeparator + TSCORE.metaFolder + TSCORE.dirSeparator + newName; TSCORE.IO.renameFilePromise(element.path, newFilePath); if (pathOld == TSCORE.currentPath) { element.name = newName; element.path = newFilePath; } else { TSCORE.metaFileList.splice(index, 1); } } else { TSCORE.IO.deleteFilePromise(element.path).then(function() { TSCORE.metaFileList.splice(index, 1); }); } } });
}), function() { TSCORE.IO.deleteFilePromise(filePath).then(function() { TSPOSTIO.deleteElement(filePath); }, function(error) { TSCORE.hideLoadingAnimation(); TSCORE.showAlertDialog("Deleting file " + filePath + " failed."); console.error("Deleting file " + filePath + " failed " + error); } ); });
filePathList.forEach(function(filePath) { fileDeletionPromises.push(TSCORE.IO.deleteFilePromise(filePath)); });