posixfs: a name below a non-directory object does not exist - #228
Merged
ThomasWaldmann merged 1 commit intoSep 24, 2026
Merged
Conversation
Accessing a name whose parent is an object (a file), e.g. "config/config" when "config" is a file, raised a raw NotADirectoryError from info/load/delete/hash on POSIX, and the REST server turned that into an HTTP 500. On Windows, the OS reports such a path as not found, so the same access gave ObjectNotFound there. Treat NotADirectoryError like FileNotFoundError in info, load, delete and hash, so posixfs (and REST via posixfs) behaves the same on all platforms, like sftp and s3 already do. rmdir/list keep raising NotADirectoryError: there, it means that the name itself is not a directory, not that it does not exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ThomasWaldmann
force-pushed
the
posixfs-notadirectory
branch
from
September 24, 2026 18:09
8aca5b8 to
5675e49
Compare
ThomasWaldmann
added a commit
to ThomasWaldmann/borg
that referenced
this pull request
Sep 24, 2026
…detection borgstore 0.6.4 (borgbackup/borgstore#228) reports a name below an object as ObjectNotFound on all platforms (posixfs raised a raw NotADirectoryError on POSIX, which the REST server turned into an HTTP 500), so a borg 1.x repository now always takes the ObjectNotFound branch of _load_config. Remove the "except Exception" branch and only catch backend and OS errors around the probe of the config file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accessing a name whose parent is an object (a file) behaved differently depending on the platform. An example is
config/configwhenconfigis a file, which is what borg 2 sees when it opens a borg 1.x repository.info/load/delete/hashraised a rawNotADirectoryError(ENOTDIR, not wrapped). The REST server turned that into an HTTP 500, so the REST client raised arequests.HTTPError.ObjectNotFound(and an HTTP 404 via REST).This PR treats
NotADirectoryErrorlikeFileNotFoundErrorin posixfsinfo,load,deleteandhash. posixfs (and REST in front of posixfs) now behaves the same on all platforms, as sftp and s3 already do: OpenSSH's sftp-server reports ENOTDIR as "no such file", and s3 has no directories.rmdir/listkeep raisingNotADirectoryError. For those, it means the name itself is not a directory, not that the name doesn't exist.rclone is not changed. With a local-path remote, rclone answers ENOTDIR with HTTP 500 (which also gets retried), so it raises
BackendError. Matching rclone's error text would be fragile, so the new test skips rclone with a TODO. Cloud remotes have no directories, so they are not affected.Test:
test_parent_is_an_objectruns on all tested backends. It fails for posixfs and REST without this change and passes with it.Motivation: borg can then detect a borg 1.x repository with a plain
except ObjectNotFoundinstead of a catch-allexcept Exception, see borgbackup/borg#10418.🤖 Generated with Claude Code