Skip to content

Commit

Permalink
feat(putio): ensure a file deletion would not happen when cleanup tas…
Browse files Browse the repository at this point in the history
…k runs
  • Loading branch information
RoyXiang committed Jul 26, 2024
1 parent d0a6932 commit 3fbd733
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion putio/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ func (put *Put) GetFileInfo(id int64) *FileInfo {
}

func (put *Put) DeleteFile(id int64) bool {
put.mu.Lock()
defer put.mu.Unlock()

ctx := context.Background()
if _, err := put.Client.Files.Get(ctx, id); err != nil {
// file may be deleted by user
// file may be deleted by user (or cleanup task)
return true
}
err := put.Client.Files.Delete(ctx, id)
Expand Down

0 comments on commit 3fbd733

Please sign in to comment.