diff options
author | Mathnerd314 <mathnerd314.gph+hs@gmail.com> | 2016-06-18 11:06:31 -0600 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2016-06-22 20:15:42 +0000 |
commit | 9a779563bbfcc35fc1a891b74003619fd4556104 (patch) | |
tree | a36437987aed2115ce9375952913ff1d25ee8115 /src/libostree/ostree-repo-refs.c | |
parent | 23049bbd011924b1e34514b14e58d82519346d36 (diff) | |
download | ostree-9a779563bbfcc35fc1a891b74003619fd4556104.tar.gz |
refs: Fix a logic error
I encountered the Opening remotes/ dir error with some broken pull code, and this fixes it.
Closes: #358
Approved by: cgwalters
Diffstat (limited to 'src/libostree/ostree-repo-refs.c')
-rw-r--r-- | src/libostree/ostree-repo-refs.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/libostree/ostree-repo-refs.c b/src/libostree/ostree-repo-refs.c index 1eb50e0c..b18d838e 100644 --- a/src/libostree/ostree-repo-refs.c +++ b/src/libostree/ostree-repo-refs.c @@ -809,8 +809,10 @@ _ostree_repo_write_ref (OstreeRepo *self, goto out; } - if (!glnx_opendirat (refs_remotes_dfd, remote, TRUE, &dfd, error)) + dfd = glnx_opendirat_with_errno (refs_remotes_dfd, remote, TRUE); + if (dfd < 0 && (errno != ENOENT || rev != NULL)) { + glnx_set_error_from_errno (error); g_prefix_error (error, "Opening remotes/ dir %s: ", remote); goto out; } @@ -818,13 +820,16 @@ _ostree_repo_write_ref (OstreeRepo *self, if (rev == NULL) { - if (unlinkat (dfd, ref, 0) != 0) + if (dfd >= 0) { - if (errno != ENOENT) - { - glnx_set_error_from_errno (error); - goto out; - } + if (unlinkat (dfd, ref, 0) != 0) + { + if (errno != ENOENT) + { + glnx_set_error_from_errno (error); + goto out; + } + } } } else |