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
This commit is contained in:
parent
37f275d94b
commit
4d326bf0d9
1 changed files with 2 additions and 6 deletions
|
@ -51,10 +51,8 @@ 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 +99,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?)
|
||||
|
|
Loading…
Reference in a new issue