matzefriedrich / zip-extensions-rs

Provides extensions for the zip crate
MIT License
20 stars 12 forks source link

`FileOptions` should be mappable #12

Closed m4heshd closed 4 months ago

m4heshd commented 6 months ago

First of all, thank you so much for this awesome extension.

I'm currently having trouble setting permissions to just a few of the files I'm adding to an archive.

What if the functionality were to be like this?

    let mut zip = ZipWriter::new(file);

    zip.create_from_directory_with_options(&PathBuf::from(&source_dir), |file: &PathBuf| {
        if file.eq(&PathBuf::from("dir/my_executable")) {
            FileOptions::default().unix_permissions(0o775)
        } else {
            FileOptions::default()
        }
    })

This allows changing the FileOptions per item inside the source directory. The file argument in the closure can be entry_path from the directory_entry_iterator.

I'd love to implement this but it would obviously be a breaking change. There's also the option of dedicating a whole new function for this. 🤔

m4heshd commented 6 months ago

Just implemented this in https://github.com/m4heshd/zip-extensions-rs/commit/4096c01c1cebfcf5015c6150257e600ae40d3ce8. I'll be using that for the moment. If you think it's worth a merge, I'll go ahead and create a PR.

matzefriedrich commented 6 months ago

Hi Mahesh,

many thanks for your efforts and your lovely message. It would be a breaking change, but we can do it. We will change the crate´s minor version to express breaking changes so developers can quickly see that there could be issues that need addressing during an upgrade. Even though the changes are few, gimme some time to think about it; feel free to open the PR, which might make it easier to carve it out and discuss things before finally merging it.

Kind regards Matthias

m4heshd commented 6 months ago

Hey Matthias,

Glad I got a quick response from you. I'll initiate a PR as soon as possible. I'll be of help as much as I'm able to, for this feature to go live.

matzefriedrich commented 4 months ago

@m4heshd I merged your PR into the development branch in preparation for a new release.

m4heshd commented 4 months ago

@matzefriedrich That's wonderful news. Can't wait for the feature to go live.