Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new feature: Add 'overwrite' Attribute to OpCopy and OpWrite #5024

Open
1 task
miniliuke opened this issue Aug 20, 2024 · 1 comment
Open
1 task

new feature: Add 'overwrite' Attribute to OpCopy and OpWrite #5024

miniliuke opened this issue Aug 20, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@miniliuke
Copy link

miniliuke commented Aug 20, 2024

Feature Description

This feature would allow users to toggle the default behavior of overwriting existing files. By enabling this attribute, the system would throw an error if the file already exists, rather than overwriting it by default.

Problem and Solution

Currently, there is no way to prevent the default behavior of overwriting target files during write (creation) or copy operations. This feature would solve this issue by providing an option to control whether an existing file should be overwritten.

Additional Context

No response

Are you willing to contribute to the development of this feature?

  • Yes, I am willing to contribute to the development of this feature.
@miniliuke miniliuke added the enhancement New feature or request label Aug 20, 2024
@Xuanwo
Copy link
Member

Xuanwo commented Aug 20, 2024

Thank you for bringing this up. Producing an error when the file exists is a significant feature. However, it would be better to implement it in a compatible way. Perhaps we can follow the if-match pattern and add an if-absent or if-not-exist option.

User can use this feature like:

let _ = op.write_with(path).if_absent(true).await?;

Or maybe just:

let _ = op.write_with(path).if_none_match("*").await?;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants