Skip to content

Commit 9728067

Browse files
committed
Revert "test"
This reverts commit b453e37.
1 parent b453e37 commit 9728067

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -535,23 +535,23 @@ def export_project() -> flask.Response:
535535
export_vease_path = os.path.join(project_folder, filename)
536536

537537
with get_session() as session:
538-
data_ids = [row.id for row in session.query(Data.id).all()]
538+
rows = session.query(Data.id, Data.native_file).all()
539539

540540
with zipfile.ZipFile(
541541
export_vease_path, "w", compression=zipfile.ZIP_DEFLATED
542542
) as zip_file:
543543
database_root_path = os.path.join(project_folder, "project.db")
544-
zip_file.write(database_root_path, "project.db")
544+
if os.path.isfile(database_root_path):
545+
zip_file.write(database_root_path, "project.db")
545546

546-
for data_id in data_ids:
547+
for data_id, native_file in rows:
547548
base_dir = os.path.join(project_folder, data_id)
548-
for root, directories, files in os.walk(base_dir):
549-
for file_name in files:
550-
file_path = os.path.join(root, file_name)
551-
zip_file.write(
552-
file_path,
553-
os.path.join(data_id, os.path.relpath(file_path, base_dir)),
554-
)
549+
if os.path.isdir(base_dir):
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))
555555

556556
zip_file.writestr("snapshot.json", flask.json.dumps(params.snapshot))
557557

@@ -624,19 +624,21 @@ def import_project() -> flask.Response:
624624
if viewable_name:
625625
vpath = geode_functions.data_file_path(data.id, viewable_name)
626626
viewable_dir = os.path.join(data_path, "viewable")
627+
has_components = os.path.isdir(viewable_dir) and bool(
628+
os.listdir(viewable_dir)
629+
)
627630
if os.path.isfile(vpath) and (
628-
data.viewer_object != "model"
629-
or (os.path.isdir(viewable_dir) and os.listdir(viewable_dir))
631+
data.viewer_object != "model" or has_components
630632
):
631633
continue
632634

633-
native_file = data.native_file
635+
native_file = str(data.native_file or "")
634636
if not native_file:
635-
flask.abort(400, "Missing native file")
637+
continue
636638

637639
native_full = geode_functions.data_file_path(data.id, native_file)
638640
if not os.path.isfile(native_full):
639-
flask.abort(400, f"Missing native file: {native_file}")
641+
continue
640642

641643
geode_object = geode_functions.geode_object_from_string(
642644
data.geode_object

0 commit comments

Comments
 (0)