mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 13:00:39 +00:00
feat: optimize attachment handling in backup process
This commit is contained in:
+20
-18
@@ -218,26 +218,28 @@ async function executeConfiguredBackup(
|
|||||||
: 'txt_backup_remote_run_progress_sync_attachments_skipped_detail',
|
: 'txt_backup_remote_run_progress_sync_attachments_skipped_detail',
|
||||||
});
|
});
|
||||||
const remoteSession = createRemoteBackupTransferSession(destination);
|
const remoteSession = createRemoteBackupTransferSession(destination);
|
||||||
const remoteAttachmentIndex = await loadRemoteAttachmentIndex(remoteSession);
|
if (destination.includeAttachments) {
|
||||||
let attachmentIndexChanged = false;
|
const remoteAttachmentIndex = await loadRemoteAttachmentIndex(remoteSession);
|
||||||
for (const attachment of archive.manifest.attachmentBlobs || []) {
|
let attachmentIndexChanged = false;
|
||||||
if (remoteAttachmentIndex.get(attachment.blobName) === attachment.sizeBytes) {
|
for (const attachment of archive.manifest.attachmentBlobs || []) {
|
||||||
continue;
|
if (remoteAttachmentIndex.get(attachment.blobName) === attachment.sizeBytes) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const remotePath = `attachments/${attachment.blobName}`;
|
||||||
|
const object = await getBlobObject(env, attachment.blobName);
|
||||||
|
if (!object) {
|
||||||
|
throw new Error(`Attachment blob missing for ${attachment.blobName}`);
|
||||||
|
}
|
||||||
|
const bytes = new Uint8Array(await new Response(object.body).arrayBuffer());
|
||||||
|
await remoteSession.putFile(remotePath, bytes, {
|
||||||
|
contentType: object.contentType,
|
||||||
|
});
|
||||||
|
remoteAttachmentIndex.set(attachment.blobName, attachment.sizeBytes);
|
||||||
|
attachmentIndexChanged = true;
|
||||||
}
|
}
|
||||||
const remotePath = `attachments/${attachment.blobName}`;
|
if (attachmentIndexChanged) {
|
||||||
const object = await getBlobObject(env, attachment.blobName);
|
await saveRemoteAttachmentIndex(remoteSession, remoteAttachmentIndex);
|
||||||
if (!object) {
|
|
||||||
throw new Error(`Attachment blob missing for ${attachment.blobName}`);
|
|
||||||
}
|
}
|
||||||
const bytes = new Uint8Array(await new Response(object.body).arrayBuffer());
|
|
||||||
await remoteSession.putFile(remotePath, bytes, {
|
|
||||||
contentType: object.contentType,
|
|
||||||
});
|
|
||||||
remoteAttachmentIndex.set(attachment.blobName, attachment.sizeBytes);
|
|
||||||
attachmentIndexChanged = true;
|
|
||||||
}
|
|
||||||
if (attachmentIndexChanged) {
|
|
||||||
await saveRemoteAttachmentIndex(remoteSession, remoteAttachmentIndex);
|
|
||||||
}
|
}
|
||||||
let upload: Awaited<ReturnType<typeof uploadBackupArchive>> | null = null;
|
let upload: Awaited<ReturnType<typeof uploadBackupArchive>> | null = null;
|
||||||
for (let attempt = 1; attempt <= maxArchiveUploadAttempts; attempt++) {
|
for (let attempt = 1; attempt <= maxArchiveUploadAttempts; attempt++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user