react-native-zip-archive
react-native-zip-archive copied to clipboard
Same file gives different md5 hash upon zip
Describe the bug Same file gives different md5 hash upon zip
To Reproduce Steps to reproduce the behavior:
- zip a directory twice in two different output path
- both zip files would have different hash even if the files are same if checked with expo-file-system
- 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]
Need some investment on the first question.
And we're not supporting .tar.gz archived files.
@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)