Giter Site home page Giter Site logo

Comments (16)

edjafarov avatar edjafarov commented on August 15, 2024

this is awesome idea! I had an issue with zipped mac. I will try smth like that.

from nw-updater.

adam-lynch avatar adam-lynch commented on August 15, 2024

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.

edjafarov avatar edjafarov commented on August 15, 2024

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.

adam-lynch avatar adam-lynch commented on August 15, 2024

Oh ya, didn't think of that. But when do we do the check?

from nw-updater.

edjafarov avatar edjafarov commented on August 15, 2024

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.

adam-lynch avatar adam-lynch commented on August 15, 2024

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.

adam-lynch avatar adam-lynch commented on August 15, 2024

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.

edjafarov avatar edjafarov commented on August 15, 2024

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.

adam-lynch avatar adam-lynch commented on August 15, 2024

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.

edjafarov avatar edjafarov commented on August 15, 2024

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.

adam-lynch avatar adam-lynch commented on August 15, 2024

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.

edjafarov avatar edjafarov commented on August 15, 2024

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.

adam-lynch avatar adam-lynch commented on August 15, 2024

Yeah, good idea.

from nw-updater.

edjafarov avatar edjafarov commented on August 15, 2024

was it fixed?

from nw-updater.

adam-lynch avatar adam-lynch commented on August 15, 2024

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.

edjafarov avatar edjafarov commented on August 15, 2024

ok

from nw-updater.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.