Skip to content
Merged
1 change: 1 addition & 0 deletions news/changelog-1.9.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ All changes included in 1.9:

### Confluence

- ([#12558](https://github.com/quarto-dev/quarto-cli/issues/12558)): Fix 500 error when updating multiple Confluence attachments. Attachments are now uploaded sequentially instead of concurrently. (author: @fkgruber)
- ([#13414](https://github.com/quarto-dev/quarto-cli/issues/13414)): Be more forgiving when Confluence server returns malformed JSON response. (author: @m1no)

### `gh-pages`
Expand Down
21 changes: 16 additions & 5 deletions src/publish/confluence/confluence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import {
} from "./confluence-verify.ts";
import {
DELETE_DISABLED,
ATTACHMENT_UPLOAD_DELAY_MS,
DELETE_SLEEP_MILLIS,
DESCENDANT_PAGE_SIZE,
EXIT_ON_ERROR,
Expand Down Expand Up @@ -435,15 +436,25 @@ async function publish(
LogPrefix.ATTACHMENT,
);

const uploadAttachmentsResult = await Promise.all(
uploadAttachments(
const uploadAttachmentsResult: (AttachmentSummary | null)[] = [];

for (let i = 0; i < attachmentsToUpload.length; i++) {
// Start exactly ONE upload by calling the helper with a single attachment
const tasks = uploadAttachments(
publishFiles.baseDir,
attachmentsToUpload,
[attachmentsToUpload[i]], // <-- one at a time
toUpdate.id,
fileName,
existingAttachments,
),
);
);

const res = await tasks[0];
uploadAttachmentsResult.push(res);

if (i < attachmentsToUpload.length - 1) {
await sleep(ATTACHMENT_UPLOAD_DELAY_MS);
}
}
trace(
"uploadAttachmentsResult",
uploadAttachmentsResult,
Expand Down
3 changes: 3 additions & 0 deletions src/publish/confluence/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const V2EDITOR_METADATA = {

export const DELETE_SLEEP_MILLIS = 1000; //TODO replace with polling

// Empirically determined delay to avoid Confluence 500 errors on concurrent attachment updates
export const ATTACHMENT_UPLOAD_DELAY_MS = 800;

export const CAN_SET_PERMISSIONS_DISABLED = "CONFLUENCE_LOCAL_STORAGE_CAN_SET_PERMISSIONS_DISABLED";

export const CAN_SET_PERMISSIONS_ENABLED_CACHED = "CONFLUENCE_LOCAL_STORAGE_CAN_SET_PERMISSIONS_ENABLED_CACHED"
Loading