mirror of https://git.48k.eu/ogclient
live: remove old image and checksum file on download
Restoring an updated image file (with different checksum) could fail while the old checksum file could remain in place. Remove image and checksum file before fetching the new files.master
parent
49017c00ca
commit
1376b1900d
|
@ -185,8 +185,16 @@ class OgLiveOperations:
|
|||
|
||||
Implies a unicast transfer. Does not use tiptorrent.
|
||||
"""
|
||||
src = f'/opt/opengnsys/images/{image_name}.img'
|
||||
dst = f'{OG_CACHE_IMAGE_PATH}{image_name}.img'
|
||||
try:
|
||||
if os.path.exists(dst):
|
||||
os.unlink(dst)
|
||||
if os.path.exists(f"{dst}.full.sum"):
|
||||
os.unlink(f"{dst}.full.sum")
|
||||
except OSError as e:
|
||||
raise OgError(f"Error deleting file {e.filename}: {e.strerror}") from e
|
||||
|
||||
src = f'/opt/opengnsys/images/{image_name}.img'
|
||||
try:
|
||||
logging.info(f'Fetching image {image_name} from {src}')
|
||||
logging.info('*DO NOT REBOOT OR POWEROFF* the client during this time')
|
||||
|
|
|
@ -101,6 +101,12 @@ def tip_check_csum(tip_addr, image_name):
|
|||
def tip_client_get(tip_addr, image_name):
|
||||
"""
|
||||
"""
|
||||
image_path = f"{OG_CACHE_IMAGE_PATH}{image_name}.img"
|
||||
if os.path.exists(image_path):
|
||||
os.unlink(image_path)
|
||||
if os.path.exists(f"{image_path}.full.sum"):
|
||||
os.unlink(f"{image_path}.full.sum")
|
||||
|
||||
logging.info(f'Fetching image {image_name} from tiptorrent server at {tip_addr}')
|
||||
logging.info('*DO NOT REBOOT OR POWEROFF* the client during this time')
|
||||
cmd = f'tiptorrent-client {tip_addr} {image_name}.img'
|
||||
|
|
Loading…
Reference in New Issue