Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

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.

share|improve this answer
    
The archives are being uploaded to dropbox and i'd like to avoid unnecessarily uploading files that have not changed –  Conrad Sep 18 '11 at 8:50
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.