Skip to content

Commit

Permalink
Fix Last Updated Time for New Game
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhhhojeihsu committed Feb 14, 2025
1 parent 92a0143 commit f9c51aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion steamCloudSaveDownloader/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;");
Expand All @@ -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):
Expand Down
6 changes: 4 additions & 2 deletions steamCloudSaveDownloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

'''
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit f9c51aa

Please sign in to comment.