Comments (16)
this is awesome idea! I had an issue with zipped mac. I will try smth like that.
from nw-updater.
Should this module handle this though?
Or should we just suggest users to add it to the packages field and to make sure and check it with fs.statSync
before running updater.download
?
Or we could add a public method which will validate it?
from nw-updater.
To download packages we are using request, we can get headers content-length to know the size of package. Then we can compare with what we have on filesystem, right?
from nw-updater.
Oh ya, didn't think of that. But when do we do the check?
from nw-updater.
I would say somewhere https://github.com/edjafarov/node-webkit-updater/blob/master/app/updater.js#L66 here. Right after the package was downloaded.
from nw-updater.
Ok. I was also thinking about the chance that the size of the file on disk might not be the right size by the time the unpacking was done (let's say you download updates in the background and the user updates whenever they decide). But I don't think this is worth worrying about.
from nw-updater.
Wait, what if I kill my nw.exe
while the download is ongoing? This check will never be done right?
Let's say when I get the manifest, but downloading a package, I first check if it already exists in the temp directory, it could be there but the file size would be wrong (i.e. corrupted). Because of this case, would it make sense for the user to be able to validate the already downloaded package?
Again, keep in mind, I don't know much about corrupted downloads.
from nw-updater.
Well. We are talking about package, right? zip
This is one file. I assume that it has a length. And if the length is right then this is it. The package is not corrupted. And high chances are that it will be unpacked properly.
Checksum would be more awesome, but that would require additional requirements for server that would handle the packages.
from nw-updater.
And if the length is right then this is it.
If I start the download, kill my node-webkit app (and therefore the download). Then I want to unpack it later, do we know "the length is right"?
Even if the user was told of the file length to expected, before the download is started. A callback or something. Then I could save that somewhere, so I can look it up later and compare it to the actual file size.
from nw-updater.
well I assume you won't be able to start from unpacking if you killed the app during downloading.
You still have old app in your folder thus it will check that there is difference in versions and would start downloading.
from nw-updater.
I'm in the middle of building a update system for my node-webkit app. When it downloads an update, it keeps track filepath. Then if at any point it tries to download it again, it first checks does it already exist.
So, the download is started, the download is killed (my download callback is never called), but the next time it tries to download, it looks in the temp directory and it already exists.
I guess I need to persist the filepath in localStorage or something and then when I check if it already exists before downloading, I need to check localStorage too and if it's not there, then I delete it from the temp dir and re-download.
I think that makes sense so.
I can try adding the bit where it validates the size against the header after downloading today.
from nw-updater.
yeah, you right. Let the updater be lower level. At least it would tell you that the downloaded package is valid. What would you do with that information is your business.
You also can move the file to specific temp folder if it was downloaded properly/completely.
from nw-updater.
Yeah, good idea.
from nw-updater.
was it fixed?
from nw-updater.
The advice should be to move the download to another folder when done.
Since I now check for the statusCode of the response, this won't download 0KB files for 404s, etc.
From my quick research, request don't seem to advise / allow you to get the content-length and check it afterwards. I can't remember the other reasons, but moving to another folder and checking the response code is enough.
from nw-updater.
ok
from nw-updater.
Related Issues (20)
- Update fails "EBUSY" "icudtl.dat" HOT 1
- NW 013.0-rc1 Uncaught TypeError: Cannot read property 'requireNwGui' of undefined HOT 2
- Alternative to unzip.exe HOT 1
- Uncaught TypeError: Cannot read property 'requireNwGui' of undefined HOT 2
- Cannot read property 'Symbol(Symbol.iterator)' of null
- invalid version at SemVer HOT 1
- Windows package with zip:false will not update HOT 3
- Unable to copy downloaded app updates from temp path to app path HOT 2
- How to pass user-data-dir path? HOT 1
- Command failed: hdiutil attach
- Options in checkNewVersion function
- Unable to download multiple files simultaneously
- Request to relocate repo to NW Utils HOT 2
- unpack callback is never called HOT 1
- Update fails with "EBUSY" when trying to `rmdir` folder (Windows XP) HOT 4
- possible to use with web2executable?
- Local\Temp\[object Object] "The system cannot find the path specified"?
- Unpack step failing occasionally with code 9 HOT 2
- Some Forks Seem Critical. Repo Still Active? HOT 2
- Unzip.exe not compatible with 64-bit versions of windows HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nw-updater.