plexus-archiver
plexus-archiver copied to clipboard
UnArchiver fails to extract files if the target exists and is read-only
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?