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
This commit is contained in:
Mathnerd314 2016-06-18 11:06:31 -06:00 committed by Atomic Bot
parent 23049bbd01
commit 9a779563bb
1 changed files with 12 additions and 7 deletions

View File

@ -809,14 +809,18 @@ _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;
}
}
if (rev == NULL)
{
if (dfd >= 0)
{
if (unlinkat (dfd, ref, 0) != 0)
{
@ -827,6 +831,7 @@ _ostree_repo_write_ref (OstreeRepo *self,
}
}
}
}
else
{
if (!write_checksum_file_at (self, dfd, ref, rev, cancellable, error))