Skip to content

Commit

Permalink
Fix updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenshin9977 committed Jan 18, 2023
1 parent 7f0b569 commit 3ec89c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
if __name__ == "__main__":
fire.Fire(videodl_logger)
logger.debug("Updating the app")
update_succeeded = update_app()
if update_succeeded:
app_has_been_updated = update_app()
if not app_has_been_updated:
logger.debug("GUI's startup")
videodl_gui()

Expand Down
14 changes: 8 additions & 6 deletions updater/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,18 @@ def get_latest_version(self) -> str:
ARCHITECTURE = "x86"
return latest_version

def update_app(self) -> None:
def update_app(self) -> bool:
"""
Check if a new version of the app is available. Download it if there is
Returns:
bool: Whether or not the app has been updated
"""
if not self._new_version_is_available():
log.info("No newer version found")
return
return False
log.info("New version found")
ft.app(target=self._download_and_replace)
self.page.window_close()
sys.exit(0)
return True

def _new_version_is_available(self) -> bool:
"""
Expand Down Expand Up @@ -191,6 +192,8 @@ def _download_and_replace(self, page: ft.Page) -> None:
raise AssertionError
log.info("Restarting...")
self._replace_with_latest(latest_archive_name)
self.page.window_close()
sys.exit(0)

def _download_latest_version(self, latest_archive_name: str) -> None:
"""
Expand Down Expand Up @@ -397,11 +400,10 @@ def update_progress_bar(

def update_app() -> bool:
try:
Updater().update_app()
return Updater().update_app()
except PermissionError:
ft.app(target=permission_error_gui)
return False
return True


def permission_error_gui(page: ft.Page):
Expand Down
2 changes: 1 addition & 1 deletion utils/sys_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import flet as ft

APP_NAME = "video-dl"
APP_VERSION = "1.0.7"
APP_VERSION = "1.0.8"
PLATFORM = system()
VERSIONS_ARCHIVE_NAME = "versions.zip"
VERSIONS_JSON_NAME = "versions.json"
Expand Down

0 comments on commit 3ec89c7

Please sign in to comment.