Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Support for avoiding overwrite upon opening archive #22

Closed
schollz opened this issue Feb 11, 2017 · 8 comments · Fixed by #99
Closed

Support for avoiding overwrite upon opening archive #22

schollz opened this issue Feb 11, 2017 · 8 comments · Fixed by #99
Assignees
Milestone

Comments

@schollz
Copy link

schollz commented Feb 11, 2017

Hi @mholt, this is a great tool/library!

I've found it useful to avoid overwriting files if they already exist when opening an archive to a folder. I'm wondering if you'd like to incorporate this as an option to your library? Here's my change: schollz@8b912ca. Of course, it would need to be amended so it can be toggled as optional.

@mholt
Copy link
Owner

mholt commented Feb 11, 2017

Are you sure? I thought we already don't overwrite existing files when extracting...

@schollz
Copy link
Author

schollz commented Feb 11, 2017

Not sure, but here is the behavior I'm getting. I have two files, and I archive only one of them. After archiving and then opening the archive in the same folder, the modified timestamp of the extracted file that came from the archive changes (from 15:52 to 15:53). My thinking was that this should only happen if the archiver is overwriting, since the modification date is changed.

$ ls -l
total 8However
-rw-rw-r-- 1 zns zns  29 Feb 11 15:52 in_archive.txt
-rw-rw-r-- 1 zns zns  29 Feb 11 15:49 not_in_archive.txt
$ archiver make test.tar.bz2 in_archive.txt
$ archiver open test.tar.bz2               
$ ls -l
total 12
-rw-rw-r-- 1 zns zns  29 Feb 11 15:53 in_archive.txt
-rw-rw-r-- 1 zns zns  29 Feb 11 15:49 not_in_archive.txt
-rw-rw-r-- 1 zns zns 169 Feb 11 15:53 test.tar.bz2

The problem this creates, for me, is that when I re-archive the exact same file it creates a "different" archive because of the modified timestamp, and I'm using the md5 hashes to test differences in local/remote archives.

$ varchiver make test2.tar.bz2 in_archive.txt
$ md5sum *tar*                              
03eed92b4b87c4da5870fc50df9a48a9  test2.tar.bz2
7509268dc83ae1a630ffdaa54a1779d2  test.tar.bz2

@mholt
Copy link
Owner

mholt commented Mar 30, 2017

Hmm, maybe we are now. I don't think that is intended. Want to submit a PR? :) Basically, return an error if a file already exists when extracting. Should just be a few lines. (Test welcome too if you're able!) I'm just super busy with stuff right now.

@schollz
Copy link
Author

schollz commented Mar 30, 2017

Sure! I'd be happy to!

@johnarok
Copy link
Contributor

johnarok commented Aug 25, 2018

@schollz would you be interested in submitting the PR? checking again as its been a while

@Vishal-Bedi
Copy link

Is this change live? when I try to unarchive a file, it still overrides an existing one

@johnarok
Copy link
Contributor

Not yet! Would you be willing to test your scenario using PR branch? #89

@mholt
Copy link
Owner

mholt commented Nov 6, 2018

This feature is under way in #99

@mholt mholt added this to the 3.0 milestone Nov 6, 2018
@mholt mholt self-assigned this Nov 6, 2018
@mholt mholt mentioned this issue Nov 7, 2018
15 tasks
@mholt mholt closed this as completed in 5105dc1 Nov 7, 2018
mholt pushed a commit that referenced this issue Nov 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants