Skip to content

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

@Tyrannican

Description

@Tyrannican

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions