delta: Add --if-not-exists option
I often want to have "idempotent" systems that iterate to a known state. If after generating a commit, the system is interrupted, I'd like the next run to still generate a delta. But we don't want to regenerate if one exists, hence this option. Closes: #375 Approved by: jlebon
This commit is contained in:
1 parent
8933c93a55
commit
0d07c7ecde
6 files changed
+66
-1
No files matched your search
@@ -819,6 +819,39 @@ _ostree_repo_static_delta_delete (OstreeRepo *self,
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_ostree_repo_static_delta_query_exists (OstreeRepo *self,
|
||||
const char *delta_id,
|
||||
gboolean *out_exists,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autofree char *from = NULL;
|
||||
g_autofree char *to = NULL;
|
||||
g_autofree char *superblock_path = NULL;
|
||||
struct stat stbuf;
|
||||
|
||||
_ostree_parse_delta_name (delta_id, &from, &to);
|
||||
superblock_path = _ostree_get_relative_static_delta_superblock_path (from, to);
|
||||
|
||||
if (fstatat (self->repo_dir_fd, superblock_path, &stbuf, 0) < 0)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
*out_exists = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
glnx_set_error_from_errno (error);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
*out_exists = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_ostree_repo_static_delta_dump (OstreeRepo *self,
|
||||
const char *delta_id,
|
||||
|
||||
Reference in new issue
Block a user