anfragment / zen

Simple, free and efficient ad-blocker and privacy guard for Windows, macOS and Linux
https://zenprivacy.net
MIT License
2.39k stars 60 forks source link

First party selfupdate #139

Closed AitakattaSora closed 6 days ago

AitakattaSora commented 2 weeks ago

Recreated commits from this PR

closes #91

AitakattaSora commented 1 week ago

@anfragment I reviewed all your comments and made the suggested adjustments. Thank you very much for the thorough feedback, it’s truly appreciated.

anfragment commented 1 week ago

@AitakattaSora after some manual testing, I came across a couple issues:

  1. On macOS, self-updater assumes that the app is located under /Applications, which might not always be the case. I believe using os.Executable() to determine the path dynamically might be a better choice.
  2. The binary might be launched via a symlink. This can be handled using filepath.EvalSymlinks.
  3. The self-updater doesn't handle rollbacks when a file or directory overwrite fails. A possible solution is to first rename the binary or app bundle to its current name with a .old suffix. If an error occurs, it can be reverted by renaming it back.
AitakattaSora commented 1 week ago

@anfragment I unified the update process by utilizing a temporary directory for unarchiving across all platforms. I also implemented unique backup name generation using a timestamp to prevent conflicts in cases where a previous update was aborted and the backup file remained in storage.