From 765e5d03d8207f38125c9426ff91c5f5cb5c9f89 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Sun, 3 Feb 2019 21:49:00 -0500 Subject: [PATCH] fix keep existent --- qfieldsync/core/layer.py | 6 ++++-- qfieldsync/core/offline_converter.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/qfieldsync/core/layer.py b/qfieldsync/core/layer.py index 9995dfea..a7462bf9 100644 --- a/qfieldsync/core/layer.py +++ b/qfieldsync/core/layer.py @@ -180,9 +180,11 @@ def copy(self, target_path, copied_files, keep_existent=False): source_path, file_name = os.path.split(file_path) basename, extensions = get_file_extension_group(file_name) for ext in extensions: - if os.path.exists(os.path.join(source_path, basename + ext)): + dest_file = os.path.join(target_path, basename + ext) + if os.path.exists(os.path.join(source_path, basename + ext)) and \ + (keep_existent is False or not os.path.isfile(dest_file)): shutil.copy(os.path.join(source_path, basename + ext), - os.path.join(target_path, basename + ext)) + dest_file) uri.setDatabase(os.path.join(target_path, file_name)) self._change_data_source(uri.uri()) return copied_files diff --git a/qfieldsync/core/offline_converter.py b/qfieldsync/core/offline_converter.py index 02c026be..110be584 100644 --- a/qfieldsync/core/offline_converter.py +++ b/qfieldsync/core/offline_converter.py @@ -125,7 +125,7 @@ def convert(self): elif layer_source.action == SyncAction.NO_ACTION: copied_files = layer_source.copy(self.export_folder, copied_files) elif layer_source.action == SyncAction.KEEP_EXISTENT: - layer_source.copy(self.export_folder, True) + layer_source.copy(self.export_folder, copied_files, True) elif layer_source.action == SyncAction.REMOVE: project.removeMapLayer(layer)