From bf0f63a9cee12f49c8824827d079f661686ffc0c Mon Sep 17 00:00:00 2001
From: ptresson <paul.tresson@ird.fr>
Date: Mon, 10 Mar 2025 17:07:02 +0100
Subject: [PATCH] change merge file counter with current batch. More
 informative and less error prone. see #45

---
 encoder.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/encoder.py b/encoder.py
index 437f3c1..8f33702 100644
--- a/encoder.py
+++ b/encoder.py
@@ -516,7 +516,6 @@ class EncoderAlgorithm(IAMAPAlgorithm):
         ## will update if process is canceled by the user
         self.all_encoding_done = True
 
-        merged_files_counter = 0
 
         for current, sample in enumerate(dataloader):
             if current <= last_batch_done:
@@ -619,8 +618,7 @@ class EncoderAlgorithm(IAMAPAlgorithm):
                 ]
                 all_tiles = [f for f in all_tiles if not f.startswith("merged")]
 
-                dst_path = Path(os.path.join(self.output_subdir, f"{merged_files_counter}_merged_tmp.tif"))
-                merged_files_counter += 1
+                dst_path = Path(os.path.join(self.output_subdir, f"{current}_merged_tmp.tif"))
 
                 try:
                     merge_tiles(
-- 
GitLab