fix: Collection names with slashes produce invalid export output
closes #3368
This commit is contained in:
@@ -12,7 +12,6 @@ import parseTitle from "@shared/utils/parseTitle";
|
||||
import { APM } from "@server/logging/tracing";
|
||||
import { User } from "@server/models";
|
||||
import dataURItoBuffer from "@server/utils/dataURItoBuffer";
|
||||
import { deserializeFilename } from "@server/utils/fs";
|
||||
import parseImages from "@server/utils/parseImages";
|
||||
import { FileImportError, InvalidRequestError } from "../errors";
|
||||
import attachmentCreator from "./attachmentCreator";
|
||||
@@ -192,7 +191,7 @@ async function documentImporter({
|
||||
throw InvalidRequestError(`File type ${mimeType} not supported`);
|
||||
}
|
||||
|
||||
let title = deserializeFilename(fileName.replace(/\.[^/.]+$/, ""));
|
||||
let title = fileName.replace(/\.[^/.]+$/, "");
|
||||
let text = await fileInfo.getMarkdown(content);
|
||||
text = text.trim();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import Attachment from "@server/models/Attachment";
|
||||
import Collection from "@server/models/Collection";
|
||||
import Document from "@server/models/Document";
|
||||
import { NavigationNode } from "~/types";
|
||||
import { serializeFilename } from "./fs";
|
||||
import { deserializeFilename, serializeFilename } from "./fs";
|
||||
import parseAttachmentIds from "./parseAttachmentIds";
|
||||
import { getFileByKey } from "./s3";
|
||||
|
||||
@@ -164,7 +164,7 @@ export async function archiveCollections(collections: Collection[]) {
|
||||
|
||||
for (const collection of collections) {
|
||||
if (collection.documentStructure) {
|
||||
const folder = zip.folder(collection.name);
|
||||
const folder = zip.folder(serializeFilename(collection.name));
|
||||
|
||||
if (folder) {
|
||||
await addDocumentTreeToArchive(folder, collection.documentStructure);
|
||||
@@ -225,7 +225,7 @@ export function zipAsFileTree(zip: JSZip) {
|
||||
const newPart = {
|
||||
name,
|
||||
path: filePath.replace(/^\//, ""),
|
||||
title: path.parse(path.basename(name)).name,
|
||||
title: deserializeFilename(path.parse(path.basename(name)).name),
|
||||
children: [],
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user