Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index is checking write access despite assuming read-only access #247

Open
LuckyLub opened this issue Aug 25, 2022 · 3 comments
Open

Index is checking write access despite assuming read-only access #247

LuckyLub opened this issue Aug 25, 2022 · 3 comments

Comments

@LuckyLub
Copy link

Context

When passing a filename to the Index class, it assumes that the file can not be overwritten unless explicitly set by the user.

rtree/rtree/index.py

Lines 240 to 244 in 81cc81a

# assume if the file exists, we're not going to overwrite it
# unless the user explicitly set the property to do so
if os.path.exists(p):
self.properties.overwrite = bool(kwargs.get("overwrite", False))

However, passing a file which is in a read-only dir is not allowed, since it is checked if the provided file is within a directory with write access.

rtree/rtree/index.py

Lines 255 to 256 in 81cc81a

if not os.access(d, os.W_OK):
message = "Unable to open file '%s' for index storage" % f

Expected behavior

When the provided file is within a read-only directory, but overwrite self.properties.overwrite = False the no OSError should be raised.

@jason-curtis
Copy link

This is also causing problems for me - my .idx is pre-cached and not writeable since I'm running on AWS Lambda. I can copy the files out to the .tmp directory but I'd rather not!

@jason-curtis
Copy link

I took a crack at this in #281, removing the check in rtree. Unfortunately the same check is happening in libspatialindex when we call down to the C code: https://libspatialindex.org/en/latest/doxygen/DiskStorageManager_8cc_source.html#l00173 .

So we could remove the checks on the Python level, but this would need to be pushed to the libspatialindex maintainers.

@mwtoews
Copy link
Member

mwtoews commented Sep 13, 2023

You could raise an issue and/or PR for libspatialindex; the source code on GitHub is here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants