Skip to content

Commit b453e37

Browse files
committed
test
1 parent 3d2e764 commit b453e37

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 15 additions & 17 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-
rows = session.query(Data.id, Data.native_file).all()
538+
data_ids = [row.id for row in session.query(Data.id).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-
if os.path.isfile(database_root_path):
545-
zip_file.write(database_root_path, "project.db")
544+
zip_file.write(database_root_path, "project.db")
546545

547-
for data_id, native_file in rows:
546+
for data_id in data_ids:
548547
base_dir = os.path.join(project_folder, data_id)
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))
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+
)
555555

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

@@ -624,21 +624,19 @@ 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-
)
630627
if os.path.isfile(vpath) and (
631-
data.viewer_object != "model" or has_components
628+
data.viewer_object != "model"
629+
or (os.path.isdir(viewable_dir) and os.listdir(viewable_dir))
632630
):
633631
continue
634632

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

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

643641
geode_object = geode_functions.geode_object_from_string(
644642
data.geode_object

0 commit comments

Comments
 (0)