Skip to content

Commit

Permalink
Fixed ID checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayy001 committed Oct 21, 2023
1 parent 1e7d765 commit 04b6bb1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions data/version-ids.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"2.10.2.356": "Lp90j3g4at-"
},
"remarkable2": {
"3.8.0.1944": "7eGpAv7sYB",
"3.7.0.1930": "XSMSQgBATy",
"3.6.1.1894": "T2dkdktE1H",
"3.6.0.1865": "7wgexMSZP5-",
"3.5.2.1807": "3bZjC0Xn5C-",
Expand Down
22 changes: 13 additions & 9 deletions modules/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,30 @@ def get_version_ids(self):
if os.name == 'nt':
folder_location = os.getenv('APPDATA') + '/codexctl'
elif os.name == 'posix':
folder_location = os.path.expanduser('~/.config')
folder_location = os.path.expanduser('~/.config/codexctl')

self.logger.debug(f'Folder location is {folder_location}')
if not os.path.exists(folder_location):
os.mkdir(folder_location)

file_location = folder_location + 'version-ids.json'
file_location = folder_location + '/version-ids.json'

if not os.path.exists(file_location):
self.update_version_ids(file_location)

with open(file_location, 'r') as f:
contents = json.load(f)
self.logger.debug(f'Contents are {contents}')

if contents['last-updated'] - int(datetime.now().timestamp()) > 2628000: # 1 month
self.update_version_ids(file_location)
try:
with open(file_location) as f:
contents = json.load(f)
except ValueError:
raise SystemExit(f'Error: version-ids.json @ {file_location} is corrupted! Please delete it and try again.')

if int(datetime.now().timestamp()) - contents['last-updated'] > 2628000: # 1 month
self.update_version_ids(file_location)
with open(file_location) as f:
contents = json.load(f)

return contents
self.logger.debug(f'Contents are {contents}')
return contents

def get_version(self, device=2, version=None, download_folder=None):
if download_folder is None:
Expand Down

0 comments on commit 04b6bb1

Please sign in to comment.