1

I'm writing a PowerShell script that does the following.

  1. Does an SVN export of a Subversion repository to a temporary folder
  2. Zips the contents of the temp folder into a 7-Zip archive
  3. Compares the MD5 hash of this file to that of a destination file
  4. If the hash is different, (that is, the file has changed) overwrite the destination archive with this one

I noticed something curious. The hashes of the 7z archives are always different even if the contents of the files themselves have not changed. Presumably because the timestamps are different?

Is this by design?

How can I get the hashes of the 7-Zip archives to be the same if the files have not changed?

3 Answers 3

2

It's likely by design. I couldn't find any detailed documentation on the 7z format, but some archive formats contain such information as "date added", indicating when the file was added to the archive, and such.

My suggestions are: 1) don't bother with comparing, just replace the old file; 2) use the update function in 7z u to update the old file in-place.

1
  • The archives are being uploaded to dropbox and i'd like to avoid unnecessarily uploading files that have not changed
    – Conrad
    Sep 18, 2011 at 8:50
1

If the file timestamps are the problem, you can try setting the SVN configuration option use-commit-times (as a command-line option, --config-option config:miscellany:use-commit-times=yes, I think).

It will set the file timestamps to the commit time of each file rather than the current time. However, the documentation does not say whether that option applies to svn export.

0

You could build a manifest with a hash of everything (except itself) and include that in the zip file. Extract and check that to see if there's been an update.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .