From 5115b11da4b98c33a4b07c32f6470d16a8d893f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Stelmach?= Date: Tue, 19 Sep 2023 17:00:09 +0200 Subject: [PATCH] WIP: report an error when an image already exist MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I3c4f2d45f42340f265bd2e4747a511ad52b1550f Signed-off-by: Łukasz Stelmach --- scripts/tizen/sd_fusing.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index 687dd240ca..61ebcf4142 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/sd_fusing.py @@ -181,13 +181,17 @@ def check_device(args): global Device Device = args.device - if not os.path.exists(Device) and args.create: - logging.debug(f"dd if=/dev/zero of={Device} conv=sparse bs=1M count={args.size}") - rc = subprocess.run(["dd", "if=/dev/zero", f"of={Device}", - "conv=sparse", "bs=1M", f"count={args.size}"]) - if rc.returncode != 0: - logging.error("Failed to create the backing file") + if args.create: + if os.path.exists(Device): + logging.error(f"Failed to create '{Device}', the file alread exists") sys.exit(1) + else: + logging.debug(f"dd if=/dev/zero of={Device} conv=sparse bs=1M count={args.size}") + rc = subprocess.run(["dd", "if=/dev/zero", f"of={Device}", + "conv=sparse", "bs=1M", f"count={args.size}"]) + if rc.returncode != 0: + logging.error("Failed to create the backing file") + sys.exit(1) if os.path.isfile(Device): global File -- 2.34.1