Add OstreeRepo option for an out-of-band cache dir

This allows you to have a writable cache dir even for a system-owned
repository.

Closes: #250
Approved by: cgwalters
This commit is contained in:
Alexander Larsson authored and Colin Walters (automation) committed 2016-04-14 15:55:08 +00:00
1 parent b787fce612
commit 9e7e594907
8 files changed
+81 -1

No files matched your search

+30
View File
@@ -2573,6 +2573,36 @@ ostree_repo_set_disable_fsync (OstreeRepo *self,
self->disable_fsync = disable_fsync;
}
/**
* ostree_repo_set_cache_dir:
* @self: An #OstreeRepo
* @dfd: directory fd
* @path: subpath in @dfd
*
* Set a custom location for the cache directory used for e.g.
* per-remote summary caches. Setting this manually is useful when
* doing operations on a system repo as a user because you don't have
* write permissions in the repo, where the cache is normally stored.
*/
gboolean
ostree_repo_set_cache_dir (OstreeRepo *self,
int dfd,
const char *path,
GCancellable *cancellable,
GError **error)
{
int fd;
if (!glnx_opendirat (dfd, path, TRUE, &fd, error))
return FALSE;
if (self->cache_dir_fd != -1)
close (self->cache_dir_fd);
self->cache_dir_fd = fd;
return TRUE;
}
/**
* ostree_repo_get_disable_fsync:
* @self: An #OstreeRepo