Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same file gives different md5 hash upon zip #314

Open
abbasiArbisoft opened this issue Sep 12, 2024 · 2 comments
Open

Same file gives different md5 hash upon zip #314

abbasiArbisoft opened this issue Sep 12, 2024 · 2 comments

Comments

@abbasiArbisoft
Copy link

abbasiArbisoft commented Sep 12, 2024

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]
@plrthink
Copy link
Collaborator

Need some investment on the first question.

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

@abbasiArbisoft
Copy link
Author

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants