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

Error Not Being Raised for Non Existent Zip #3

Closed
cancan101 opened this issue Nov 25, 2015 · 13 comments
Closed

Error Not Being Raised for Non Existent Zip #3

cancan101 opened this issue Nov 25, 2015 · 13 comments
Labels

Comments

@cancan101
Copy link

Tis is calling the then rather than catch where the specified file does not exist:

   ZipArchive.unzip(RNFS.CachesDirectoryPath + '/XXXXX.zip', RNFS.CachesDirectoryPath + '/YYYY')
      .then((o) => {
        alert('o: ' + o)
      })
      .catch((error) => {
        alert('E: ' + error)
      });
@cancan101
Copy link
Author

The same seems to happen with the file exists but is not a valid zip.

@plrthink
Copy link
Collaborator

plrthink commented Dec 2, 2015

@cancan101 I will fix this ASAP.

@plrthink plrthink added the bug label Dec 2, 2015
@WestleyArgentum
Copy link

Also seeing this problem...

But even when the file exists and is a valid zip, this doesn't seem to work... any tips on debugging?

@plrthink
Copy link
Collaborator

@WestleyArgentum I'm using react-native-fs to get access to the zip file on the simulator to check the it. I think any methods which can get path to the zip file is ok.

I would improve this.

@WestleyArgentum
Copy link

I'm using react-native-fs to download the zip, and I use RNFS.readDir to check and make sure the zip file is downloaded correctly... but then when I try to unzip it nothing happens and I don't see any errors...

@plrthink
Copy link
Collaborator

@WestleyArgentum You mean the promise is just hanging?

@plrthink
Copy link
Collaborator

@WestleyArgentum I think maybe you're dong something wrong wth promise code, e.g. not return the promise from the inner promise chain which I have ran into before.

@WestleyArgentum
Copy link

Sorry I disappeared there, but in this case I don't think the error is promise related -- my code is just like the example:

    ZipArchive.unzip(RNFS.DocumentDirectoryPath + '/images.zip', RNFS.DocumentDirectoryPath)
            .then(() => {
                // check to see what exists in the directory...
                RNFS.readDir(RNFS.DocumentDirectoryPath)
                  .then((result) => {
                    // shows images.zip, but not an unzipped folder or any of the contents of the zip...
                    console.log('things in directory:', result);
                });
            })
            .catch((err) => {
                cb(err);
            });

Does that look ok?

@WestleyArgentum
Copy link

Ah, I realized I can use xcode to step through the code and my problem was with directories. Would be really cool to have those errors raised through .catch though

Thanks for your help!

@plrthink
Copy link
Collaborator

plrthink commented Mar 1, 2016

@WestleyArgentum oh, can you explain a little bit about your resolution? So I can collect errors should be raised.

@WestleyArgentum
Copy link

So, I've never spent much time in objective c, but I think the problem is here: https://github.com/plrthink/react-native-zip-archive/blob/master/RNZipArchive.m#L19

It looks like these methods take in a pointer to a pointer to an error: https://github.com/plrthink/react-native-zip-archive/blob/fb47345d3094e7e85bf49af747758acea7fe43d3/SSZipArchive/SSZipArchive.m#L47

And that you should pass that in, check if it gets set, and raise an error instead of calling the callback

@plrthink
Copy link
Collaborator

plrthink commented Jun 1, 2016

fixed with b622cb0

@plrthink plrthink closed this as completed Jun 1, 2016
@WestleyArgentum
Copy link

nice, thanks!

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

No branches or pull requests

3 participants