bugGNU Octave - Bugs: bug #67161, Change unzip behavior to overwrite...

 
 

bug #67161: Change unzip behavior to overwrite rather than skip existing files

Submitter:  Volkmar Glauche <glauche>
Submitted:  Mon 26 May 2025 07:43:03 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 10.1.0 Release: 
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 30 May 2025 01:03:02 PM UTC, comment #5: 

Unarchiver tests in the test suite all pass with this change.
I don't know if BISTs need to be adapted, can you have a look?

IMO (and yours) just changing unzip's behavior to silently overwrite existing files suffices, no extra flags / options are needed. Adapting bug report title correspndingly & Item group.

Still some doc changes are required but that does not necessarily belong to this bug report. I'll see if I can have a go at that later on.

Philip Nienhuis <philipnienhuis>
Group Member
Tue 27 May 2025 12:11:23 PM UTC, comment #4: 


> IMO, the easiest thing would be to harmonise unzip behaviour to unconditionally overwrite files as well. This would need to be documented, of course...

Agreed.
Pimping unzip with extra option flags for e.g., not overwriting etc. can always be done later. And (my preference) we can simply leave responsibility to the user to first figure out which files need to be extracted / overwritten and then specify those explicitly in the unpack / unzip calls.

If so the bug report title should be adapted.

Yet some reminiscences of bug #45331 (from 10 years ago) slowly come back - it may be that there was a reason then to not unconditionally overwrite files; even if that introduced the Matlab incompatibility, unintended or not. Perhaps s/th like hanging or aborting on read-only locations or so. I have to read back on it, and obviously SW has changed in the mean time. Proper testing is required in any case.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 26 May 2025 08:32:47 PM UTC, comment #3: 

IMO, the easiest thing would be to harmonise unzip behaviour to unconditionally overwrite files as well. This would need to be documented, of course...

A patch to replace "-n/-nq" options with "-o/-oq" in the call to unzip is included.

(file #57243)

Volkmar Glauche <glauche>
Mon 26 May 2025 10:22:22 AM UTC, comment #2: 

Apart from Matlab compatibility, Octave's behavior w.r.t. overwriting (or not) existing files should be documented. Perusing the help texts of the various unzip/unbzip2/ungzip/... functions I found that none of them makes any mention of it.

Trying a bit I see that gzip & bunzip2 unconditionally overwrite existing files, unzip doesn't.

@glauche:
Could you come up with a cset or patch, please?
If I may ask, also better help and some BISTs?  I know, I'm asking a lot :-) but we are all volunteers here with limited time.

BTW behavior of not overwriting files confirmed on Windows as well, and present in 10.1.0 and dev Octave.
Assuming it also applies to MacOS, "Operating System" => "Any"

BTW, in bug #45331 some related issues were mentioned.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 26 May 2025 08:42:09 AM UTC, comment #1: 

This is actually also a MATLAB compatibility issue - MATLAB always tries to overwrite existing files with ZIP archive contents.

Volkmar Glauche <glauche>
Mon 26 May 2025 07:43:03 AM UTC, original submission:  

When unpacking a ZIP archive, octave uses


'unzip -n'


as system command. This does not refresh or overwrite existing files, and it does return a filename list for the actually unzipped files only. Octave documentation does not mention the "no overwrite" behaviour.

In my usecase, I would like unzip to update existing datasets. It would be ok to refresh or overwrite data. However, processing steps on the updated datasets will need to work on the entire list of files in a dataset .zip, not just the refreshed or newly unpacked ones.

To achieve that with the current implementation of unzip in octave, I would have to ensure to unpack the archive into a clean location and merge it into the target location afterwards. If there was an option to set desired unzip behaviour (overwrite "-o", freshen "-f" or no overwrite "-n"), it would give more control to users how they would like to deal with possible file collisions and which file names they can expect in the output list.

Volkmar Glauche <glauche>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by philipnienhuis (Posted a comment)
  • -email is unavailable- added by glauche (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-05-30 philipnienhuis Item GroupFeature Request Matlab Compatibility
        SummaryAdd overwrite/update mode option to unzip Change unzip behavior to overwrite rather than skip existing files
    2025-05-26 glauche Attached File- Added unpack_unzip_overwrite.diff, #57243
    2025-05-26 philipnienhuis Release9.2.0 10.1.0
        Operating SystemGNU/Linux Any

    Back to the top

    Powered by Savane 3.15-26b0.
    Corresponding source code