From e63d83fc7f2113c8de0f8ab85665c5ea190c1f75 Mon Sep 17 00:00:00 2001 From: gryf Date: Tue, 8 Feb 2022 20:38:59 +0100 Subject: [PATCH] Don't clutter current directory with checksum files. In case of Centos, there is a need to get the checksum file first to figure out the correct image filename, during that process checksum file was left alone in the current directory. Place it in the temp dir in the first place and than remove after we know the right image filename. --- box.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/box.py b/box.py index 0da784d..675c693 100755 --- a/box.py +++ b/box.py @@ -1012,12 +1012,13 @@ class CentosStream(Image): self._img_url = self.URL % (version, arch, self._img_fname) def _get_image_name(self, version, arch): - Run(['wget', self._checksum_url, '-q', '-O', self._checksum_file]) + fname = os.path.join(self._tmp, self._checksum_file) + Run(['wget', self._checksum_url, '-q', '-O', fname]) pat = re.compile(self.IMG % (version, arch)) images = [] - with open(self._checksum_file) as fobj: + with open(fname) as fobj: for line in fobj.read().strip().split('\n'): line = line.strip() if line.startswith('#'): @@ -1026,6 +1027,7 @@ class CentosStream(Image): if match and match.groups(): images.append(match.groups()[0]) + Run(['rm', fname]) images.reverse() if images: return images[0]