WIP: report an error when an image already exist
authorŁukasz Stelmach <l.stelmach@samsung.com>
Tue, 19 Sep 2023 15:00:09 +0000 (17:00 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 20 Sep 2023 12:15:00 +0000 (14:15 +0200)
Change-Id: I3c4f2d45f42340f265bd2e4747a511ad52b1550f
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
scripts/tizen/sd_fusing.py

index 687dd24..61ebcf4 100755 (executable)
@@ -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