diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-03-05 20:32:53 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-03-05 21:00:15 +0100 |
commit | a213a7bfa82b7171b90c415cbdb44d469e747ece (patch) | |
tree | 8eb7829314684dabab1d3f51b97740420aec9895 | |
parent | 68581754f3a37e7712e3983acfeff0ff598e4eb6 (diff) | |
download | libgit2-a213a7bfa82b7171b90c415cbdb44d469e747ece.tar.gz |
refdb: catch a directory disappearing
If a directory disappears between the time we look up the entries of its
parent and the time when we go to look at it, we should ignore the error
and move forward.
This fixes #2046.
-rw-r--r-- | src/path.c | 3 | ||||
-rw-r--r-- | src/refdb_fs.c | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/path.c b/src/path.c index 89409eae4..fa800b74c 100644 --- a/src/path.c +++ b/src/path.c @@ -853,6 +853,9 @@ int git_path_direach( if ((dir = opendir(path->ptr)) == NULL) { giterr_set(GITERR_OS, "Failed to open directory '%s'", path->ptr); + if (errno == ENOENT) + return GIT_ENOTFOUND; + return -1; } diff --git a/src/refdb_fs.c b/src/refdb_fs.c index 43682f40e..3219b0519 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -272,9 +272,17 @@ static int _dirent_loose_load(void *payload, git_buf *full_path) if (git__suffixcmp(full_path->ptr, ".lock") == 0) return 0; - if (git_path_isdir(full_path->ptr)) - return git_path_direach( + if (git_path_isdir(full_path->ptr)) { + int error = git_path_direach( full_path, backend->direach_flags, _dirent_loose_load, backend); + /* Race with the filesystem, ignore it */ + if (error == GIT_ENOTFOUND) { + giterr_clear(); + return 0; + } + + return error; + } file_path = full_path->ptr + strlen(backend->path); |