From c71eb4124d6acaaa517a828d3f32797d7c5596cd Mon Sep 17 00:00:00 2001 From: Sean Gillies Date: Mon, 15 Jul 2024 14:18:50 -0600 Subject: [PATCH 1/2] Implement truncate plugin callback --- CHANGES.txt | 7 +++++++ Makefile | 2 +- fiona/_vsiopener.pyx | 14 +++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 430044bc..cef6a0e2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,6 +3,13 @@ Changes All issue numbers are relative to https://github.com/Toblerity/Fiona/issues. +1.10.0rc1 (TBD) +--------------- + +Bug fixes: + +- The truncate VSI plugin callback has been implemented (#). + 1.10b2 (2024-07-10) ------------------- diff --git a/Makefile b/Makefile index 8a7e7bcf..3e17db9f 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ dockertestimage: docker build --target gdal --build-arg GDAL=$(GDAL) --build-arg PYTHON_VERSION=$(PYTHON_VERSION) -t fiona:$(GDAL)-py$(PYTHON_VERSION) . dockertest: dockertestimage - docker run -it -v $(shell pwd):/app -v /tmp:/tmp --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --entrypoint=/bin/bash fiona:$(GDAL)-py$(PYTHON_VERSION) -c '/venv/bin/python -m pip install tiledb && /venv/bin/python -m pip install -vvv --editable .[all] --no-build-isolation && /venv/bin/python -B -m pytest -m "not wheel" --cov fiona --cov-report term-missing $(OPTS)' + docker run -it -v $(shell pwd):/app -v /tmp:/tmp --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --entrypoint=/bin/bash fiona:$(GDAL)-py$(PYTHON_VERSION) -c '/venv/bin/python -m pip install -vvv --editable .[all] --no-build-isolation && /venv/bin/python -B -m pytest -m "not wheel" --cov fiona --cov-report term-missing $(OPTS)' dockershell: dockertestimage docker run -it -v $(shell pwd):/app --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --entrypoint=/bin/bash fiona:$(GDAL)-py$(PYTHON_VERSION) -c '/venv/bin/python -m pip install --editable . --no-build-isolation && /bin/bash' diff --git a/fiona/_vsiopener.pyx b/fiona/_vsiopener.pyx index 0babadfe..9eb80aed 100644 --- a/fiona/_vsiopener.pyx +++ b/fiona/_vsiopener.pyx @@ -288,7 +288,8 @@ cdef size_t pyopener_write(void *pFile, void *pBuffer, size_t nSize, size_t nCou "Writing data: file_obj=%r, buff_view=%r, buffer_len=%r", file_obj, buff_view, - buffer_len) + buffer_len + ) try: num = file_obj.write(buff_view) except TypeError: @@ -306,6 +307,16 @@ cdef int pyopener_flush(void *pFile) with gil: return 1 +cdef int pyopener_truncate(void *pFile, vsi_l_offset size) with gil: + cdef object file_obj = pFile + log.debug("Truncating: file_obj=%r, size=%r", file_obj, size) + try: + file_obj.truncate(size) + return 0 + except AttributeError: + return 1 + + cdef int pyopener_close(void *pFile) with gil: cdef object file_obj = pFile log.debug("Closing: file_obj=%r", file_obj) @@ -373,6 +384,7 @@ def _opener_registration(urlpath, obj): callbacks_struct.read = pyopener_read callbacks_struct.write = pyopener_write callbacks_struct.flush = pyopener_flush + callbacks_struct.truncate = pyopener_truncate callbacks_struct.close = pyopener_close callbacks_struct.read_dir = pyopener_read_dir callbacks_struct.stat = pyopener_stat From b55f79b4d5912d5ac6f56698cd587d90d7ba40bb Mon Sep 17 00:00:00 2001 From: Sean Gillies Date: Mon, 15 Jul 2024 14:38:21 -0600 Subject: [PATCH 2/2] Update change log --- CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index cef6a0e2..08e3ff4f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,7 +8,7 @@ All issue numbers are relative to https://github.com/Toblerity/Fiona/issues. Bug fixes: -- The truncate VSI plugin callback has been implemented (#). +- The truncate VSI plugin callback has been implemented (#1413). 1.10b2 (2024-07-10) -------------------