alexanderwe / the-traveler

The Traveler is a small npm package which wraps around the Destiny 2 API.
https://alexanderwe.github.io/the-traveler/
MIT License
56 stars 10 forks source link

Manifest Issue #30

Closed Jakosaur closed 6 years ago

Jakosaur commented 6 years ago

Can download the manifest fine, but then when I then try to download the manifest again I get

Error: EPERM: operation not permitted, open 'mylongfilepath\world_sql_content_d122ea6e6d07e448d34868985f7a9cb9.content.zip'

alexanderwe commented 6 years ago

Hey @Jakosaur,

thanks for submitting this issue. I tried to reproduce what you said, but I was unable to get the error you posted. Can you give me a short code block in which your error appears and which I can try to run to figure out what the problem is ? That would be very nice

Jakosaur commented 6 years ago

I've just been using the example on the GitHub page. I run this when I start up the program, which works fine, but when I try to refresh the manifest it gives the error

traveler.getDestinyManifest().then(result => { traveler.downloadManifest(result.Response.mobileWorldContentPaths.en, './manifest.content').then(filepath => { const manifest = new Manifest(filepath); manifest.queryManifest('SELECT name FROM sqlite_master WHERE type="table"').then(queryResult => { console.log(queryResult); }).catch(err => { console.log(err); }); }).catch(err => { console.log(err); }) })

alexanderwe commented 6 years ago

I assume you are on Windows right ? Which version of the-traveler are you using ?

Jakosaur commented 6 years ago

Yeah Windows. v-0.7.1

Jakosaur commented 6 years ago

I've done a new Node Project from scratch, all I did was the normal npm init, npm install the-traveler & npm install sqlite3

Then ran this code

Still throws the error. It seems when the manifest function is called the second time, it deletes the ZIP and then tries to open it?

alexanderwe commented 6 years ago

Thanks for the code snippet. I was able to reproduce the issue on a windows machine.

The idea was to unzip the zip file and if it is unzipped delete it right away, leaving the directory with the unzipped Sqlite3 database. I will investigate what exactly is happening there

alexanderwe commented 6 years ago

I am not sure how fast I can get a solution for this. Feel free to also investigate the issue on your own. I assume it must be somewhere in those lines https://github.com/alexanderwe/the-traveler/blob/master/src/Traveler.ts#L1084-L1094. It seems I try to open the .zip but is not there.

I assume the following happens:

  1. Download .zip
  2. Unzip it
  3. Delete .zip
  4. Somehow do not download it again
  5. Try to open .zip but is deleted from the previous call

Also be aware to not post your API key publicly

Jakosaur commented 6 years ago

Thanks for pointing my key is on there haha, I even made a note to remove it before uploading the code. At least its a new key I made this morning

Jakosaur commented 6 years ago

What I've noticed is that if the program ends the .zip is deleted. If the program continues running after the manifest is refreshed, the .zip stays in File Explorer "until" the downloadManifest function is called again.

alexanderwe commented 6 years ago

Resolved with pull-request #31 Thanks again for investigating and resolving this issue. Helps a lot 👍 I will publish a new version with your fix to npm