Coder Social home page Coder Social logo

Self-update on windows about cargo-update HOT 14 CLOSED

mzji avatar mzji commented on August 26, 2024
Self-update on windows

from cargo-update.

Comments (14)

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024 2

Good to know, will read up on that, cheers

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024 1

Now old versions are removed at start, thanks for the suggestion

from cargo-update.

mzji avatar mzji commented on August 26, 2024

Another reference: Self-deleting Executables

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

I failed to make a cmd process that hangs around after the main exec dies so that's POC for now

from cargo-update.

mzji avatar mzji commented on August 26, 2024

@nabijaczleweli I'm thinking to write a Windows-only method to do self-deleting
Gist will be here later

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

In the last resource you linked there's a mention of MoveFileEx() with MOVEFILE_DELAY_UNTIL_REBOOT, that sounds pretty ideal

from cargo-update.

mzji avatar mzji commented on August 26, 2024

@nabijaczleweli That won't help users which don't reboot frequently

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

I envisioned it as first moving it so the update will succeed then marking the moved (still running, but useless after it dies) exec as to delete at shutdown.
That way the user will have the updated version straight away and the old one (now renamed to sth like cargo-install-update.exe-v0.3.0) will silently stop existing at shutdown when it's no longer used.

from cargo-update.

mzji avatar mzji commented on August 26, 2024

@nabijaczleweli
The gist here is a piece of pseudo-code to implement the self-deleting
Edit: The delete-after-reboot method won't work if the old exe still exists and another new version of cargo-update is installed without reboot. It will work, however leaving some unused binaries is not good experience for users.

from cargo-update.

mzji avatar mzji commented on August 26, 2024

How about this: when user checks update, cargo-update deletes old junks.

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

That's even less ideal tbh because you delay the delete until the next time the user checks for updates instead of next shutdown (also you risk false positives)

from cargo-update.

mzji avatar mzji commented on August 26, 2024

But my method means there will be at most 1 old version living with the newest version. And if user checks update multiple times between 2 reboots (which is more common, IMHO), the old version will be deleted silently.
Or you could implement both delete-after-reboot and delete-before-update.
I don't sure I get the meaning of "false positives", could you provide more details? Thanks!
Side note: If Windows cannot find the files which are marked as "delete after reboot", then it will ignore them silently.
PS: Maybe you could move the old executable to the Windows temporary directory, then when users clear their harddisk, the old version(s) will be deleted.

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

Released in v0.4.1

from cargo-update.

mzji avatar mzji commented on August 26, 2024

Yay!

from cargo-update.

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.