g_free);
}
+/**
+ * ostree_repo_mark_commit_partial:
+ * @self: Repo
+ * @checksum: Commit SHA-256
+ * @is_partial: Whether or not this commit is partial
+ * @error: Error
+ *
+ * Commits in "partial" state do not have all their child objects written. This
+ * occurs in various situations, such as during a pull, but also if a "subpath"
+ * pull is used, as well as "commit only" pulls.
+ *
+ * This function is used by ostree_repo_pull_with_options(); you
+ * should use this if you are implementing a different type of transport.
+ *
+ * Since: 2017.15
+ */
+gboolean
+ostree_repo_mark_commit_partial (OstreeRepo *self,
+ const char *checksum,
+ gboolean is_partial,
+ GError **error)
+{
+ g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (checksum);
+ if (is_partial)
+ {
+ glnx_autofd int fd = openat (self->repo_dir_fd, commitpartial_path,
+ O_EXCL | O_CREAT | O_WRONLY | O_CLOEXEC | O_NOCTTY, 0644);
+ if (fd == -1)
+ {
+ if (errno != EEXIST)
+ return glnx_throw_errno_prefix (error, "open(%s)", commitpartial_path);
+ }
+ }
+ else
+ {
+ if (!ot_ensure_unlinked_at (self->repo_dir_fd, commitpartial_path, 0))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/**
* ostree_repo_transaction_set_refspec:
* @self: An #OstreeRepo
guint64 freed_bytes;
} OtPruneData;
-static gboolean
-prune_commitpartial_file (OstreeRepo *repo,
- const char *checksum,
- GCancellable *cancellable,
- GError **error)
-{
- g_autofree char *path = _ostree_get_commitpartial_path (checksum);
- return ot_ensure_unlinked_at (repo->repo_dir_fd, path, error);
-}
-
static gboolean
maybe_prune_loose_object (OtPruneData *data,
OstreeRepoPruneFlags flags,
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
{
- if (!prune_commitpartial_file (data->repo, checksum, cancellable, error))
+ if (!ostree_repo_mark_commit_partial (data->repo, checksum, FALSE, error))
return FALSE;
}
cancellable, error);
}
-static gboolean
-write_commitpartial_for (OtPullData *pull_data,
- const char *checksum,
- GError **error)
-{
- g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (checksum);
- glnx_autofd int fd = openat (pull_data->repo->repo_dir_fd, commitpartial_path, O_EXCL | O_CREAT | O_WRONLY | O_CLOEXEC | O_NOCTTY, 0644);
- if (fd == -1)
- {
- if (errno != EEXIST)
- return glnx_throw_errno_prefix (error, "open(%s)", commitpartial_path);
- }
- return TRUE;
-}
-
static void
enqueue_one_object_request (OtPullData *pull_data,
const char *checksum,
pull_data->cancellable, error))
goto out;
- if (!write_commitpartial_for (pull_data, checksum, error))
+ if (!ostree_repo_mark_commit_partial (pull_data->repo, checksum, TRUE, error))
goto out;
}
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
{
/* mark as partial to ensure we scan the commit below */
- if (!write_commitpartial_for (pull_data, checksum, error))
+ if (!ostree_repo_mark_commit_partial (pull_data->repo, checksum, TRUE, error))
return FALSE;
}
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
{
/* mark as partial to ensure we scan the commit below */
- if (!write_commitpartial_for (pull_data, checksum, error))
+ if (!ostree_repo_mark_commit_partial (pull_data->repo, checksum, TRUE, error))
return FALSE;
}
if (!_ostree_repo_import_object (pull_data->repo, refd_repo,
{
GLNX_HASH_TABLE_FOREACH_V (requested_refs_to_fetch, const char*, checksum)
{
- g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (checksum);
- if (!ot_ensure_unlinked_at (pull_data->repo->repo_dir_fd, commitpartial_path, 0))
+ if (!ostree_repo_mark_commit_partial (pull_data->repo, checksum, FALSE, error))
goto out;
}
GLNX_HASH_TABLE_FOREACH_V (commits_to_fetch, const char*, commit)
{
- g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (commit);
- if (!ot_ensure_unlinked_at (pull_data->repo->repo_dir_fd, commitpartial_path, 0))
+ if (!ostree_repo_mark_commit_partial (pull_data->repo, commit, FALSE, error))
goto out;
}
}