question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Header checksum is invalid on IOS downloading tar.gz file with UnityWebRequest (2019.4.8f1)

See original GitHub issue

Steps to reproduce

1.Make a request to the server to download the gziped file 2. Use all possible examples from GZip and Tar Samples to try to decompress/extract contents 3. On unity editor and Android all works fine using the method below

public static void ExtractNestedTar(string gzArchiveName, string destFolder, bool deleteOriginal, Func<string, string> fileVersionExtractor) 
{
    var tmp = Path.Combine(destFolder, "tmp");

    using (Stream inStream = File.OpenRead(gzArchiveName))
    using (TarArchive tarArchive = TarArchive.CreateInputTarArchive(inStream)) {

        tarArchive.ExtractContents(tmp);

        System.Array.ForEach(new DirectoryInfo(tmp).GetDirectories(),
            fl => Debug.Log($"Compressor: TMP file name {fl.Name}"));

        foreach (var f in new DirectoryInfo(tmp).GetFiles("*.tar")) {
            using (var s = f.OpenRead())
            using (var t = TarArchive.CreateInputTarArchive(s)) {
                string fileName = fileVersionExtractor.Invoke(f.Name);
                t.ExtractContents(Path.Combine(destFolder, fileName));
            }
        }
    }
        
    if (!deleteOriginal) return;

    File.Delete(gzArchiveName);
    Directory.Delete(tmp, true);
}

Expected behavior

Be able to extract contents from tar.gz file on IOS

Actual behavior

When trying to parse header on IOS devices the checksum is invalid since checksum obtained from ParseOctal and the one obtained from MakeCheckSum are different.
I’m attaching the tar.gz file I got from unity and from IOS (strangely both have different sizes) I’m thinking that maybe from IOS side the gzipped file gets decompressed and encoded in some way not supported, but it’s just a hypothesis. unityFile.tar.gz IOSFile.tar.gz

Version of SharpZipLib

v1.2.0

Obtained from (only keep the relevant lines)

  • Downloaded from GitHub

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
silviaPixowlcommented, Aug 28, 2020

It worked :octocat: , I’m really grateful to you!

0reactions
silviaPixowlcommented, Aug 28, 2020

Thank you very much, I’ll try this and let you know 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Header checksum is invalid #160 - icsharpcode/SharpZipLib
gz compressed file, I'm using UnityWebRequest to download the file and I've tried to extract it using the Simple full extract from a...
Read more >
Docker load and save: "archive/tar: invalid tar header"
It's a powershell issue. Powershell emits two byte characters to STDOUT, not one byte characters. If you look in the file you'll notice...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found