Skip to content

Commit 53e6f58

Browse files
committed
added 3rd param to generate viewable function to add additional files to data_id folder
1 parent 3c1b97a commit 53e6f58

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/opengeodeweb_back/utils_functions.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,19 @@ def generate_native_viewable_and_light_viewable(geode_object, data, original_fil
151151
name = data.name()
152152
object_type = geode_functions.get_object_type(geode_object)
153153

154-
additional_files_copied = []
154+
additional_files_copied = [] # List to store files that are successfully copied
155155
if original_filename:
156-
original_file_path = geode_functions.upload_file_path(original_filename)
157-
additional = geode_functions.additional_files(geode_object, original_file_path)
158-
156+
additional = geode_functions.additional_files(geode_object, original_filename)
159157
for additional_file in additional.mandatory_files + additional.optional_files:
160158
if not additional_file.is_missing:
161-
source_path = geode_functions.upload_file_path(additional_file.filename)
159+
# Construct the source path for the additional file
160+
source_path = os.path.join(
161+
os.path.dirname(original_filename), additional_file.filename
162+
)
162163
if os.path.exists(source_path):
164+
# Construct the destination path and ensure the directory exists
163165
dest_path = os.path.join(data_path, additional_file.filename)
166+
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
164167
shutil.copy2(source_path, dest_path)
165168
additional_files_copied.append(additional_file.filename)
166169

0 commit comments

Comments
 (0)