Skip to content

Commit 2508e16

Browse files
committed
fix(project): Fix Import of models
1 parent de47178 commit 2508e16

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,11 @@ def export_project() -> flask.Response:
547547
for data_id, native_file in rows:
548548
base_dir = os.path.join(project_folder, data_id)
549549
if os.path.isdir(base_dir):
550-
for f_name in os.listdir(base_dir):
551-
file_path = os.path.join(base_dir, f_name)
552-
if os.path.isfile(file_path):
553-
zip_file.write(file_path, os.path.join(data_id, f_name))
550+
for root, directories, files in os.walk(base_dir):
551+
for file_name in files:
552+
file_path = os.path.join(root, file_name)
553+
relative_path = os.path.relpath(file_path, base_dir)
554+
zip_file.write(file_path, os.path.join(data_id, relative_path))
554555

555556
zip_file.writestr("snapshot.json", flask.json.dumps(params.snapshot))
556557

@@ -620,9 +621,16 @@ def import_project() -> flask.Response:
620621
for data in rows:
621622
data_path = geode_functions.data_file_path(data.id)
622623
viewable_name = data.viewable_file
624+
viewable_directory = os.path.join(data_path, "viewable")
625+
has_component_viewables = os.path.isdir(viewable_directory) and bool(
626+
os.listdir(viewable_directory)
627+
)
628+
623629
if viewable_name:
624-
vpath = geode_functions.data_file_path(data.id, viewable_name)
625-
if os.path.isfile(vpath):
630+
viewable_path = geode_functions.data_file_path(data.id, viewable_name)
631+
if os.path.isfile(viewable_path) and (
632+
data.viewer_object != "model" or has_component_viewables
633+
):
626634
continue
627635

628636
native_file = str(data.native_file or "")

0 commit comments

Comments
 (0)