From a8ed0f2e26bca702f06bfb792f1fe465732d4a53 Mon Sep 17 00:00:00 2001
From: Felipe <fima@dtu.dk>
Date: Wed, 18 Sep 2024 10:14:28 +0200
Subject: [PATCH] Fixed existing directory check for Zarr

---
 qim3d/io/saving.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/qim3d/io/saving.py b/qim3d/io/saving.py
index ed5012aa..42f8e29f 100644
--- a/qim3d/io/saving.py
+++ b/qim3d/io/saving.py
@@ -319,7 +319,15 @@ class DataSaver:
 
         # If path is an existing directory
         if isdir:
-            # If basename is provided
+            # Check if this is a Zarr directory
+            if ".zarr" in path:
+                if self.replace:
+                    return self.save_to_zarr(path, data)
+                if not self.replace:
+                    raise ValueError(
+                        "A Zarr directory with the provided path already exists. To replace it set 'replace=True'"
+                    )
+            # If basename is provided, user wants to save as tiff stack
             if self.basename:
                 # Save as tiff stack
                 return self.save_tiff_stack(path, data)
-- 
GitLab