mirror of
https://github.com/zadam/trilium.git
synced 2026-05-06 16:45:53 +02:00
fix(core): extension lookup failing in standalone
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import type { Request } from "express";
|
||||
import path from "path";
|
||||
import type { File } from "../../services/import/common.js";
|
||||
|
||||
interface ImportRequest<P> extends Request<P> {
|
||||
@@ -12,12 +11,13 @@ import enexImportService from "../../services/import/enex.js";
|
||||
import opmlImportService from "../../services/import/opml.js";
|
||||
import singleImportService from "../../services/import/single.js";
|
||||
import zipImportService from "../../services/import/zip.js";
|
||||
import log, { getLog } from "../../services/log.js";
|
||||
import { getLog } from "../../services/log.js";
|
||||
import TaskContext from "../../services/task_context.js";
|
||||
import { safeExtractMessageAndStackFromError } from "../../services/utils/index.js";
|
||||
import * as cls from "../../services/context.js";
|
||||
import { ValidationError } from "../../errors.js";
|
||||
import becca_loader from "../../becca/becca_loader.js";
|
||||
import { extname } from "../../services/utils/path.js";
|
||||
|
||||
async function importNotesToBranch(req: ImportRequest<{ parentNoteId: string }>) {
|
||||
const { parentNoteId } = req.params;
|
||||
@@ -40,7 +40,7 @@ async function importNotesToBranch(req: ImportRequest<{ parentNoteId: string }>)
|
||||
|
||||
const parentNote = becca.getNoteOrThrow(parentNoteId);
|
||||
|
||||
const extension = path.extname(file.originalname).toLowerCase();
|
||||
const extension = extname(file.originalname).toLowerCase();
|
||||
|
||||
// running all the event handlers on imported notes (and attributes) is slow
|
||||
// and may produce unintended consequences
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { EditedNotesResponse, RevisionItem, RevisionPojo } from "@triliumnext/commons";
|
||||
import type { Request, Response } from "express";
|
||||
import path from "path";
|
||||
|
||||
import becca from "../../becca/becca.js";
|
||||
import type BNote from "../../becca/entities/bnote.js";
|
||||
@@ -10,6 +9,7 @@ import eraseService from "../../services/erase.js";
|
||||
import { NotePojo } from "../../becca/becca-interface.js";
|
||||
import { becca_service, binary_utils, cls, getSql } from "../../index.js";
|
||||
import { formatDownloadTitle, getContentDisposition } from "../../services/utils/index.js";
|
||||
import { extname } from "../../services/utils/path.js";
|
||||
|
||||
interface NotePath {
|
||||
noteId: string;
|
||||
@@ -67,7 +67,7 @@ function getRevisionFilename(revision: BRevision) {
|
||||
throw new Error("Missing creation date for revision.");
|
||||
}
|
||||
|
||||
const extension = path.extname(filename);
|
||||
const extension = extname(filename);
|
||||
const date = revision.dateCreated
|
||||
.substr(0, 19)
|
||||
.replace(" ", "_")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
import mimeTypes from "mime-types";
|
||||
import path from "path";
|
||||
import { types as extToMime } from "mime-types";
|
||||
import type { NoteType, TaskData } from "@triliumnext/commons";
|
||||
import { extname } from "../utils/path";
|
||||
|
||||
const CODE_MIME_TYPES = new Set([
|
||||
"application/json",
|
||||
@@ -84,10 +84,10 @@ function getMime(fileName: string) {
|
||||
return "text/x-dockerfile";
|
||||
}
|
||||
|
||||
const ext = path.extname(fileNameLc);
|
||||
const ext = extname(fileNameLc);
|
||||
const mimeFromExt = EXTENSION_TO_MIME.get(ext);
|
||||
|
||||
return mimeFromExt || mimeTypes.lookup(fileNameLc);
|
||||
return mimeFromExt || extToMime[ext.slice(1)] || false;
|
||||
}
|
||||
|
||||
function getType(options: TaskData<"importNotes">, mime: string): NoteType {
|
||||
|
||||
Reference in New Issue
Block a user