From f9c51aa69bd7283b2ac608474a9d6a2338edf995 Mon Sep 17 00:00:00 2001 From: Hojei Hsu Date: Fri, 14 Feb 2025 17:09:49 +0800 Subject: [PATCH] Fix Last Updated Time for New Game --- steamCloudSaveDownloader/db.py | 8 +++++++- steamCloudSaveDownloader/downloader.py | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/steamCloudSaveDownloader/db.py b/steamCloudSaveDownloader/db.py index 7665078..c007922 100644 --- a/steamCloudSaveDownloader/db.py +++ b/steamCloudSaveDownloader/db.py @@ -139,6 +139,12 @@ def get_now(self): now = now.replace(microsecond=0) return now + def get_epoch_0(self): + zero = datetime.datetime.fromtimestamp(0) + zero = zero.replace(tzinfo=None) + zero = zero.replace(microsecond=0) + return zero + def add_requests_count(self, count:int): cur = self.con.cursor() res = cur.execute("SELECT time FROM REQUESTS WHERE id = 0;"); @@ -161,7 +167,7 @@ def is_requests_limit_exceed(self) -> bool: def add_new_game(self, app_id:int, game_name:str): cur = self.con.cursor() - res = cur.execute("INSERT INTO GAMES VALUES (?, ?, NULL, ?);", (app_id, game_name, self.get_now())) + res = cur.execute("INSERT INTO GAMES VALUES (?, ?, NULL, ?);", (app_id, game_name, self.get_epoch_0())) self.con.commit() def set_game_dir(self, app_id:int, dir_name:str): diff --git a/steamCloudSaveDownloader/downloader.py b/steamCloudSaveDownloader/downloader.py index 81197ac..7fc2d99 100644 --- a/steamCloudSaveDownloader/downloader.py +++ b/steamCloudSaveDownloader/downloader.py @@ -99,8 +99,6 @@ def download_all_games(self): current_game_index = 1 for game in self.game_list: - if self.db.is_requests_limit_exceed(): - raise err.err(err.err_enum.REQUESTS_LIMIT_EXCEED) if not self.should_process_appid(game['app_id']): logger.debug(f"Ignoring {game['name']} ({game['app_id']})") continue @@ -120,7 +118,10 @@ def download_games(self, p_games: list): self.download_game(game) + @downloader_locker def download_game(self, p_game): + if self.db.is_requests_limit_exceed(): + raise err.err(err.err_enum.REQUESTS_LIMIT_EXCEED) self.update_game(p_game) ''' @@ -182,6 +183,7 @@ def update_game(self, p_game: dict): def add_new_game(self, p_game, p_file_infos): self.db.add_new_game(p_game['app_id'], p_game['name']) + self.db.set_game_last_checked_time_to_now(p_game['app_id']) self.storage.create_game_folder(p_game['name'], p_game['app_id']) file_tuples = [(file_info['filename'], file_info['path'], p_game['app_id'], file_info['time']) for file_info in p_file_infos]