From a3380cecc449a50bd1f36de84f2c803c417938fe Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 9 Apr 2022 01:30:47 +0200 Subject: [PATCH] Creata funzione di comodo per creazione dei checksum. --- loaih/__init__.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 7aae124..3ee146a 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -292,14 +292,17 @@ class Build(object): for arch in self.arch: for item in [ self.appimagefilename[arch], self.zsyncfilename[arch] ]: # For any built arch, find out if a file exist. - if not os.path.exists(f"{item}.md5"): - # Build checksum - checksum = subprocess.run(shlex.split(f"md5sum {item}"), capture_output=True, text=True, encoding='utf-8') - if checksum.stdout: - with open(f"{item}.md5", 'w+') as f: - f.write(checksum.stdout) + self.__create_checksum__(item) + def __create_checksum__(self, file): + """Internal function to create checksum file.""" + if not os.path.exists(f"{file}.md5"): + checksum = subprocess.run(shlex.split(f"md5sum {file}"), capture_output=True, text=True, encoding='utf-8') + if checksum.stdout: + with open(f"{file}.md5", 'w+') as c: + c.write(checksum.stdout) + def publish(self): """Moves built versions to definitive storage.""" if all(self.built.values()): @@ -324,6 +327,10 @@ class Build(object): # Creating versions for short version and query text versions = [ self.short_version, self.branch_version ] for arch in Build.ARCHSTD: + # If already built, do not do anything. + if self.built[arch]: + continue + os.chdir(self.full_path) # if the appimage for the reported arch is not found, skip to next # arch @@ -341,7 +348,7 @@ class Build(object): os.unlink(appimagefilename[arch]) os.symlink(self.appimagefilename[arch], appimagefilename[arch]) # Create the checksum for the AppImage - subprocess.run(shlex.split(f"md5sum {appimagefilename[arch]} > {appimagefilename[arch]}.md5")) + self.__create_checksum__(appimagefilename[arch]) # Do not continue if no zsync file is provided. if not self.updatable: continue