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

Create destination directory for LocalAsset copy / write if it does not exist #31

Closed
Tyrannican opened this issue Apr 4, 2023 · 3 comments
Labels
feature New feature or request
Milestone

Comments

@Tyrannican
Copy link

When using Asset::copy("legit-src", "non-existant-destination") or asset.write("non-existant-destination"), the call will raise an error if the destination path does not exist for a LocalAsset.

Potential solution would be to check if the destination Path is a valid directory and create it (plus any parent directories) if not using something like fs::create_dir_all before the complete destination path (including filename) is built.
e.g.

let dest_path = Path::new(dest_dir);
if !dest_path.is_dir() {
    std::fs::create_dir_all(dest_path)?;
}

If this is intended behaviour then feel free to ignore this!

@ashleygwilliams ashleygwilliams added the feature New feature or request label Apr 4, 2023
@ashleygwilliams ashleygwilliams added this to the 0.2.0 milestone Apr 4, 2023
@ashleygwilliams
Copy link
Member

hey @Tyrannican ! thanks for filing, this is actually a feature we need for our project oranda and so i'll likely implement something like this for 0.2.0 (about to cut a 0.1.0 right now)

i suspect instead of modifying the current function i'll probably build a write_all function that will create the dir if it doesn't exist. (oranda needs a few dir functions that you can see on the tracker :) )

@Tyrannican
Copy link
Author

Sounds good!

Love the project, keep up the amazing work!

@ashleygwilliams ashleygwilliams modified the milestones: 0.2.0, 0.3.0 Apr 12, 2023
@shadows-withal
Copy link
Contributor

Coincidentally, I think this'll be closed via #38.

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

No branches or pull requests

3 participants