Skip to content

UnArchiver fails to extract files if the target exists and is read-only #138

Open
@Bdot42

Description

@Bdot42

In my maven build the unpack extension is used to extract some packages like zulu or postgres, which contain read-only files (e.g. -r-xr-xr-x pgsql/lib/libssl.so.1.0.0). When re-building, I get the WARNING Unable to expand to file .../pgsql/lib/libssl.so.1.0.0 . (I created https://stackoverflow.com/questions/62836984/how-to-make-maven-unpack-overwrite-read-only-files for that)

I followed the code to the plexus archiver, where the extractFile method in AbstractUnArchiver.java is just overwriting the file without deleting it first if it exists.

Now, I'm not sure if it is a bug, an enhancement or even desired behavior, that read-only target files are not overwritten? The directory that contains it is writable, so deleting and creating a new file would work.

Would you consider something like adding ' if (f.exists()) { f.delete() } ' at around line 350? Or would that be undesired?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions