Skip to content

Commit dfe6a33

Browse files
authored
merge: merge pull request #55 from DTC-Glaciers/fix-prevent-ddos
fix: prevent writing over datacube whilst already downloading
2 parents 1bd07a0 + 3040a5c commit dfe6a33

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def setup(app):
3030
project = "DTCG"
3131
copyright = f"{date.today().year}, DTCG Contributors"
3232
author = "DTCG Contributors"
33-
release = "1.0.0"
33+
release = "1.0.1"
3434
version = os.environ.get("READTHEDOCS_VERSION", "latest")
3535

3636
# -- General configuration ---------------------------------------------------

dtcg/api/external/call.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,23 @@ def zip_datacube(self, rgi_id: str, zip_path: Path = ""):
101101
stream_url = self.get_url(rgi_id=rgi_id)
102102
try:
103103
zip_path = self.get_zip_path(zip_path=zip_path, rgi_id=rgi_id)
104-
105-
store = zarr.storage.ZipStore(zip_path, mode="w")
106-
with xr.open_datatree(
107-
stream_url,
108-
group=None,
109-
chunks={},
110-
engine="zarr",
111-
consolidated=True,
112-
decode_cf=True,
113-
) as stream:
114-
stream.compute().to_zarr(
115-
store=store,
116-
mode="w",
104+
if not zip_path.is_file():
105+
store = zarr.storage.ZipStore(zip_path, mode="w")
106+
with xr.open_datatree(
107+
stream_url,
108+
group=None,
109+
chunks={},
110+
engine="zarr",
117111
consolidated=True,
118-
zarr_format=2,
119-
# encoding=stream.encoding,
120-
)
112+
decode_cf=True,
113+
) as stream:
114+
stream.compute().to_zarr(
115+
store=store,
116+
mode="w",
117+
consolidated=True,
118+
zarr_format=2,
119+
# encoding=stream.encoding,
120+
)
121121

122122
except GroupNotFoundError as e:
123123
# pipe different error to frontends

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "dtcg"
7-
version = "1.0.0"
7+
version = "1.0.1"
88
authors = [
99
{ name = "DTCG Contributors", email = "" },
1010
]
@@ -20,7 +20,7 @@ keywords = [
2020
]
2121
classifiers = [
2222
"License :: OSI Approved :: Apache Software License",
23-
"Development Status :: 1 - Planning",
23+
"Development Status :: 5 - Production/Stable",
2424
"Private :: Do Not Upload",
2525
"Intended Audience :: Science/Research",
2626
"Operating System :: POSIX :: Linux",

0 commit comments

Comments
 (0)