lib/repo: Auto-recreate repo/tmp if it's deleted

We can accumulate a lot of space there; let's be nice to people who delete the
whole directory.

Closes: https://github.com/ostreedev/ostree/issues/1018

Closes: #1020
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-07-19 15:01:19 +00:00
1 parent c740b7f6d2
commit 779f125cbe
2 files changed
+23 -1

No files matched your search

+14
View File
@@ -2201,6 +2201,20 @@ ostree_repo_open (OstreeRepo *self,
self->target_owner_uid = self->target_owner_gid = -1;
}
if (self->writable)
{
/* Always try to recreate the tmpdir to be nice to people
* who are looking to free up space.
*
* https://github.com/ostreedev/ostree/issues/1018
*/
if (mkdirat (self->repo_dir_fd, "tmp", 0755) == -1)
{
if (G_UNLIKELY (errno != EEXIST))
return glnx_throw_errno_prefix (error, "mkdir(tmp)");
}
}
if (!glnx_opendirat (self->repo_dir_fd, "tmp", TRUE, &self->tmp_dir_fd, error))
return FALSE;