react-native-zip-archive icon indicating copy to clipboard operation
react-native-zip-archive copied to clipboard

Same file gives different md5 hash upon zip

Open abbasiArbisoft opened this issue 1 year ago • 2 comments

Describe the bug Same file gives different md5 hash upon zip

To Reproduce Steps to reproduce the behavior:

  1. zip a directory twice in two different output path
  2. both zip files would have different hash even if the files are same if checked with expo-file-system
  3. Can we use .tar.gz with this library ?

Expected behavior To have the same hash for zip files that have the same content

Env (please complete the following information):

  • Device: [e.g. iPhone 15 Pro]
  • OS: [e.g. iOS 17.5]
  • OS Version: [e.g. 14.6.1]
  • Package Version: [e.g. 6.1.0]

abbasiArbisoft avatar Sep 12 '24 07:09 abbasiArbisoft

Need some investment on the first question.

And we're not supporting .tar.gz archived files.

plrthink avatar Sep 18 '24 14:09 plrthink

@plrthink Hope this helps. Zipping the same file again doesn't maintains the file integrity. Maybe we can handle compression level to avoid zipping the meta-data e.g. timestamps.

import * as FileSystem from 'expo-file-system' import { zip } from 'react-native-zip-archive'

const source = 'path/photo.png' const target1 = 'path/zip1.zip' await zip(source, target1)

const target2 = 'path/zip2.zip' await zip(source, target2)

const zip1 = await FileSystem.getInfoAsync(target1, { md5: true, size: true })

const zip2 = await FileSystem.getInfoAsync(target2, { md5: true, size: true })

console.log('zip1', zip1.md5) console.log('zip2', zip2.md5)

abbasiArbisoft avatar Sep 18 '24 15:09 abbasiArbisoft