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

+1
View File
@@ -335,4 +335,5 @@ global:
ostree_repo_get_remote_option;
ostree_repo_get_remote_list_option;
ostree_repo_get_remote_boolean_option;
ostree_repo_set_cache_dir;
} LIBOSTREE_2016.4;
+1
View File
@@ -54,6 +54,7 @@ struct OstreeRepo {
GFile *tmp_dir;
int tmp_dir_fd;
int cache_dir_fd;
char *cache_dir;
GFile *objects_dir;
GFile *state_dir;
int objects_dir_fd;
+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
+7
View File
@@ -63,6 +63,13 @@ _OSTREE_PUBLIC
void ostree_repo_set_disable_fsync (OstreeRepo *self,
gboolean disable_fsync);
_OSTREE_PUBLIC
gboolean ostree_repo_set_cache_dir (OstreeRepo *self,
int dfd,
const char *path,
GCancellable *cancellable,
GError **error);
_OSTREE_PUBLIC
gboolean ostree_repo_get_disable_fsync (OstreeRepo *self);