Skip to content

Commit 702a2b4

Browse files
committed
delete "remove_metadata()" call when overwriting
This was calling the write metadata logic twice, incurring twice the cost of the rezipping time when overwriting md on a zipped gdb layer
1 parent ae64006 commit 702a2b4

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

dcpy/utils/geospatial/fgdb.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ def write_metadata(
4343
raise FileExistsError(
4444
"Metadata already exists, and overwrite is False. Nothing will be written"
4545
)
46-
if overwrite:
47-
remove_metadata(gdb=gdb, layer=layer)
4846

4947
xml_data = metadata.to_xml()
5048
md = xml_data.decode("utf-8") if isinstance(xml_data, bytes) else xml_data
@@ -79,7 +77,7 @@ def remove_metadata(gdb: Path, layer: str) -> None:
7977

8078

8179
# TODO: refactor this for speed. Requirement to rezip is slow for large GDBs.
82-
# With a 76MB zipped gdb, performance: unzip: 0.92s, gdal: 0.67s, rezip: 7.36s
80+
# With a 76MB zipped gdb, performance: unzip: 0.92s, gdal: 0.67s, rezip: 7.36ss
8381
def _edit_layer_metadata_inplace(
8482
gdb: Path,
8583
layer: str,
@@ -132,6 +130,5 @@ def _edit_md(
132130
z.write(
133131
filename=file, arcname=file.relative_to(uncompressed_gdb.parent)
134132
)
135-
136133
else:
137134
_edit_md(gdb=gdb, layer=layer, metadata=metadata)

0 commit comments

Comments
 (0)