Skip to content

Commit fee3a3f

Browse files
author
Allen Manning
authored
Merge pull request #4030 from quarto-dev/bug/find-attachment-windows
universal file path metadata in pages
2 parents bcf8d3c + 177d19a commit fee3a3f

File tree

4 files changed

+489
-29
lines changed

4 files changed

+489
-29
lines changed

src/publish/confluence/api/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ export class ConfluenceClient {
128128
WrappedResult<AttachmentSummary>
129129
>(`content/${id}/child/attachment`);
130130

131-
trace("getAttachments", wrappedResult, LogPrefix.ATTACHMENT);
132-
133131
const result = wrappedResult?.results ?? [];
134132
return result;
135133
}

src/publish/confluence/confluence-helper.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,12 @@ export const buildSpaceChanges = (
317317
(page: SitePage) => page?.metadata?.fileName === fileName
318318
);
319319

320-
const existingPage = findPageInExistingSite(fileMetadata.fileName);
320+
const universalFileName = pathWithForwardSlashes(fileMetadata.fileName);
321+
const existingPage = findPageInExistingSite(universalFileName);
321322

322323
let spaceChangeList: ConfluenceSpaceChange[] = [];
323324

324-
const pathList = fileMetadata.fileName.split("/");
325+
const pathList = universalFileName.split("/");
325326

326327
let pageParent =
327328
pathList.length > 1
@@ -335,6 +336,7 @@ export const buildSpaceChanges = (
335336

336337
let existingSiteParent = null;
337338

339+
//TODO update with deno paths after tests are in place
338340
const parentsList = pathList.slice(0, pathList.length - 1);
339341

340342
parentsList.forEach((parentFileName, index) => {
@@ -343,6 +345,7 @@ export const buildSpaceChanges = (
343345
const ancestor = index > 0 ? ancestorFilePath : parent?.parent;
344346

345347
let fileName = `${ancestorFilePath}/${parentFileName}`;
348+
346349
if (fileName.startsWith("/")) {
347350
fileName = parentFileName;
348351
}
@@ -407,7 +410,7 @@ export const buildSpaceChanges = (
407410
existingPage.id,
408411
useOriginalTitle ? fileMetadata.originalTitle : fileMetadata.title,
409412
fileMetadata.contentBody,
410-
fileMetadata.fileName,
413+
universalFileName,
411414
pageParent
412415
),
413416
];
@@ -418,7 +421,7 @@ export const buildSpaceChanges = (
418421
fileMetadata.title,
419422
space,
420423
fileMetadata.contentBody,
421-
fileMetadata.fileName,
424+
universalFileName,
422425
pageParent,
423426
ContentStatusEnum.current
424427
),

src/publish/confluence/confluence.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { join } from "path/mod.ts";
44
import { Input, Secret } from "cliffy/prompt/mod.ts";
55
import { RenderFlags } from "../../command/render/types.ts";
6+
import { pathWithForwardSlashes } from "../../core/path.ts";
67

78
import {
89
readAccessTokens,
@@ -244,7 +245,7 @@ async function publish(
244245

245246
const space = await client.getSpace(parent.space);
246247

247-
trace("publish", { parent, server, space });
248+
trace("publish", { parent, server, id: space.id, key: space.key });
248249

249250
const uniquifyTitle = async (title: string, idToIgnore: string = "") => {
250251
const titleAlreadyExistsInSpace: boolean = await client.isTitleInSpace(
@@ -483,10 +484,12 @@ async function publish(
483484
body: ContentBody,
484485
titleToCreate: string = title,
485486
createParent: ConfluenceParent = parent,
486-
fileName: string = ""
487+
fileNameParam: string = ""
487488
): Promise<Content> => {
488489
const createTitle = await uniquifyTitle(titleToCreate);
489490

491+
const fileName = pathWithForwardSlashes(fileNameParam);
492+
490493
const attachmentsToUpload: string[] = findAttachments(
491494
body.storage.value,
492495
publishFiles.files,
@@ -578,10 +581,9 @@ async function publish(
578581
parentId,
579582
publishFiles,
580583
metadataByInput,
584+
existingSite,
581585
});
582586

583-
trace("existingSite", existingSite);
584-
585587
const filteredFiles: string[] = filterFilesForUpdate(publishFiles.files);
586588

587589
trace("filteredFiles", filteredFiles);
@@ -654,16 +656,18 @@ async function publish(
654656
parent: ancestorId ?? siteParent.parent,
655657
};
656658

659+
const universalPath = pathWithForwardSlashes(change.fileName ?? "");
660+
657661
const result = await createContent(
658662
publishFiles,
659663
change.body,
660664
change.title ?? "",
661665
ancestorParent,
662-
change.fileName
666+
universalPath
663667
);
664668

665-
if (change.fileName) {
666-
pathsToId[change.fileName] = result.id ?? "";
669+
if (universalPath) {
670+
pathsToId[universalPath] = result.id ?? "";
667671
}
668672

669673
const contentPropertyResult: Content =

0 commit comments

Comments
 (0)