Created
May 14, 2017 20:23
-
-
Save ben-willmore/6fcb742b620085de75c22de340580f96 to your computer and use it in GitHub Desktop.
pyupdater onedir patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/pyupdater/client/updates.py b/pyupdater/client/updates.py | |
index f610963..547e60e 100644 | |
--- a/pyupdater/client/updates.py | |
+++ b/pyupdater/client/updates.py | |
@@ -624,16 +624,29 @@ class AppUpdate(LibUpdate): | |
temp_dir = get_mac_dot_app_dir(self._current_app_dir) | |
self._current_app_dir = temp_dir | |
- app_update = os.path.join(self.update_folder, self.name) | |
+ #app_update = os.path.join(self.update_folder, self.name) | |
+ # assume the .tar.gz contains exactly one file or directory in the | |
+ # top level | |
+ update_dir_or_file = os.listdir(self.update_folder)[0] | |
+ app_update = os.path.join(self.update_folder, update_dir_or_file) | |
+ | |
+ current_app_dir = self._current_app_dir | |
# Must be dealing with Mac .app application | |
if not os.path.exists(app_update): | |
app_update += '.app' | |
+ elif os.path.isdir(app_update): | |
+ # then we'll assume that the binary is only one directory | |
+ # deep in the tar.gz. The general case is tricky (e.g. if | |
+ # the binary is one dir deep in the new version, but two | |
+ # dirs deep in the old version...) | |
+ current_app_dir = os.path.dirname(self._current_app_dir) | |
+ | |
log.debug('Update Location:\n%s', os.path.dirname(app_update)) | |
log.debug('Update Name: %s', os.path.basename(app_update)) | |
- current_app = os.path.join(self._current_app_dir, self.name) | |
+ current_app = os.path.join(current_app_dir, update_dir_or_file) | |
# Must be dealing with Mac .app application | |
if not os.path.exists(current_app): | |
@@ -646,12 +659,12 @@ class AppUpdate(LibUpdate): | |
if os.path.exists(current_app): | |
remove_any(current_app) | |
- log.debug('Moving app to new location:\n\n%s', self._current_app_dir) | |
- shutil.move(app_update, self._current_app_dir) | |
+ log.debug('Moving app to new location:\n\n%s', current_app_dir) | |
+ shutil.move(app_update, current_app_dir) | |
def _restart(self): | |
log.debug('Restarting') | |
- current_app = os.path.join(self._current_app_dir, self.name) | |
+ current_app = os.path.join(self._current_app_dir, os.path.basename(sys.argv[0])) | |
if get_system() == 'mac': | |
# Must be dealing with Mac .app application | |
if not os.path.exists(current_app): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment