question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FR: Add File.delete options property to count missing file as success

See original GitHub issue

Is your feature request related to a problem? Please describe. I frequently find myself performing delete operations on files that may or may not exist. Similar to how Cloud Firestore’s delete operation works, I would like for the Cloud Storage delete operation to consider a non-existent file as a successful deletion. In other words, I want my delete operation to be considered successful if the file does not exist after the operation completes- regardless of if it did exist before the operation.

Describe the solution you’d like The delete operation (docs here) takes an optional options object, whose only parameter is currently userProject. I would like a new property to be available that I could use to enable this mechanism on a per-operation basis. The syntax might look something like:

await myBucket.file("thisFileMightNotExist.txt").delete({mustExist: false})

Describe alternatives you’ve considered The two alternatives are to either 1) run a File.exists operation first, or 2) handle deletion error in catch block. Both alternatives work, they’re just not very elegant. Alternative 1 technically also leaves an unlikely but possible scenario where the file is removed after the the exists operation but before the delete operation.

Additional context None.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stephenpluspluscommented, Dec 2, 2020

@willbattel thank you for the suggestion! 5.6.0 is out with the feature.

1reaction
stephenpluspluscommented, Dec 1, 2020

This was released upstream, and here is a PR to officially introduce it here: #1347

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove a FileList item from a multiple "input:file"
Finally found a way! I knew before that input.files would accept a FileList but the only way to get it was through a...
Read more >
ALTER DATABASE File and Filegroups - SQL Server
Removing a database file that has FILE_SNAPSHOT backups associated with it will succeed, but any associated snapshots will not be deleted to ...
Read more >
const
Uppy internally uses file objects that abstract over local files and files from remote providers, and that contain extra data like user-specified metadata...
Read more >
Complete Guide to Windows File System Auditing
The option for file auditing is the “Audit object access” option. Double-click “Audit object access” and set it to both success and failure....
Read more >
Review and troubleshoot import errors
Verify that your data value matches the correct format for the property you are importing, fix any mistakes, then re-import the file. You...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found