mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 18:50:41 +01:00
image import/export related fixes
This commit is contained in:
@@ -32,11 +32,11 @@ async function exportToTar(exportContext, branch, format, res) {
|
||||
do {
|
||||
index = existingFileNames[lcFileName]++;
|
||||
|
||||
newName = lcFileName + "_" + index;
|
||||
newName = index + "_" + lcFileName;
|
||||
}
|
||||
while (newName in existingFileNames);
|
||||
|
||||
return fileName + "_" + index;
|
||||
return index + "_" + fileName;
|
||||
}
|
||||
else {
|
||||
existingFileNames[lcFileName] = 1;
|
||||
|
||||
@@ -26,8 +26,7 @@ async function saveImage(buffer, originalName, parentNoteId, shrinkImageSwitch)
|
||||
|
||||
const parentNote = await repository.getNote(parentNoteId);
|
||||
|
||||
const fileNameWithoutExtension = originalName.replace(/\.[^/.]+$/, "");
|
||||
const fileName = sanitizeFilename(fileNameWithoutExtension + "." + imageFormat.ext);
|
||||
const fileName = sanitizeFilename(originalName);
|
||||
|
||||
const {note} = await noteService.createNote(parentNoteId, fileName, finalImageBuffer, {
|
||||
target: 'into',
|
||||
|
||||
@@ -75,8 +75,6 @@ function getMime(fileName) {
|
||||
const ext = path.extname(fileName).toLowerCase();
|
||||
|
||||
if (ext in EXTENSION_TO_MIME) {
|
||||
console.log(EXTENSION_TO_MIME[ext]);
|
||||
|
||||
return EXTENSION_TO_MIME[ext];
|
||||
}
|
||||
|
||||
@@ -108,7 +106,7 @@ async function importSingleFile(importContext, file, parentNote) {
|
||||
}
|
||||
|
||||
async function importImage(file, parentNote, importContext) {
|
||||
const {note} = await imageService.saveImage(file.buffer, getFileNameWithoutExtension(file.originalname), parentNote.noteId, importContext.shrinkImages);
|
||||
const {note} = await imageService.saveImage(file.buffer, file.originalname, parentNote.noteId, importContext.shrinkImages);
|
||||
|
||||
importContext.increaseProgressCount();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user