Switch to check files by size

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2022-11-06 18:13:45 +02:00
parent a46313ea61
commit 8424d25463

View file

@ -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')