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:
1 parent
b787fce612
commit
9e7e594907
8 files changed
+81
-1
No files matched your search
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user