From 8424d25463f8ff41736cca2cd874de23ad123eab Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 6 Nov 2022 18:13:45 +0200 Subject: [PATCH] Switch to check files by size Signed-off-by: Dimitris Zlatanidis --- slpkg/check_updates.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 512c8bc8..52473375 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -4,7 +4,6 @@ import os import urllib3 -from dateutil import parser from dataclasses import dataclass from slpkg.configs import Configs @@ -18,20 +17,19 @@ class CheckUpdates: def updates(self): - local_date = '' + local_date = 0 local_chg_txt = f'{self.sbo_repo_path}/{self.chglog_txt}' - if os.path.isfile(local_chg_txt): - with open(local_chg_txt, 'r', encoding='utf-8') as f: - local_date = f.readline().strip() - http = urllib3.PoolManager() repo = http.request( 'GET', f'{self.sbo_repo_url}/{self.chglog_txt}') - repo_date = repo.data.decode().split('\\')[0][:len(local_date)].strip() + if os.path.isfile(local_chg_txt): + local_date = int(os.stat(local_chg_txt).st_size) - if parser.parse(repo_date) > parser.parse(local_date): + repo_date = int(repo.headers['Content-Length']) + + if repo_date > local_date: print('\nThere are new updates available.\n') else: print('\nNo updated packages since the last check.\n')