From 6e7244e1e43d9ec3b52b3e2133514510a8ba25b8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 31 Dec 2024 07:49:27 +0000 Subject: [PATCH] fix: upload attachments with unique filename This prevents any clashes with uploading two files with the same name at the same time. Closes: kemitix/trello-to-deck#9 --- src/import/attachment.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/import/attachment.rs b/src/import/attachment.rs index 0db7f84..3a45183 100644 --- a/src/import/attachment.rs +++ b/src/import/attachment.rs @@ -51,10 +51,12 @@ impl Actor for ImportAttachmentActor { this.trello_attachment.name ); // - - - download the attachment from trello - let dir_path = this.ctx.temp_fs.base().join(&*this.trello_attachment.id); - let dir = this.ctx.temp_fs.dir(&dir_path); - dir.create()?; // FIXME: (#6) handle error - let file_path = dir_path.join(&*this.trello_attachment.name); + let file_name = f!( + "{}-{}", + this.trello_attachment.id, + this.trello_attachment.name + ); + let file_path = this.ctx.temp_fs.base().join(&file_name); ask!(this.rate_limit_actor, RequestToken)?; // FIXME: (#6) handle error let attachment_path = this .ctx @@ -101,8 +103,6 @@ impl Actor for ImportAttachmentActor { attachment_file .remove() .with_context(|| f!("deleting temp file {attachment_file}"))?; // FIXME: (#6) handle error - dir.remove() - .with_context(|| f!("deleting temp dir {dir}"))?; // FIXME: (#6) handle error tracing::info!("ImportAttachmentActor finished"); Ok(actor_ref.stop_gracefully().await?)