repo: Never delete .commitmeta files

Do not delete a .commitmeta file after removing the last metadata entry.
This way a client will pull the empty .commitmeta file and overwrite old
metadata as expected.

https://bugzilla.gnome.org/750459
This commit is contained in:
Matthew Barnes committed 2015-11-23 14:22:45 -05:00
1 parent 5307af5a7a
commit df75fc232a
3 files changed
+27 -19

No files matched your search

+16 -18
View File
@@ -2140,24 +2140,7 @@ ostree_repo_write_commit_detached_metadata (OstreeRepo *self,
normalized_size = g_variant_get_size (normalized);
}
if (normalized_size == 0)
{
GError *local_error = NULL;
(void) g_file_delete (metadata_path, cancellable, &local_error);
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
g_clear_error (&local_error);
}
else if (local_error != NULL)
{
g_propagate_error (error, local_error);
g_prefix_error (error, "Unable to delete detached metadata: ");
goto out;
}
}
else
if (normalized_size > 0)
{
if (!g_file_replace_contents (metadata_path,
g_variant_get_data (normalized),
@@ -2169,6 +2152,21 @@ ostree_repo_write_commit_detached_metadata (OstreeRepo *self,
goto out;
}
}
else
{
g_autoptr(GFileOutputStream) output_stream = NULL;
/* Don't write to the stream, leave the file empty. */
output_stream = g_file_replace (metadata_path,
NULL, FALSE,
G_FILE_CREATE_NONE,
cancellable, error);
if (output_stream == NULL)
{
g_prefix_error (error, "Unable to write detached metadata: ");
goto out;
}
}
ret = TRUE;
out:
+2 -1
View File
@@ -273,7 +273,8 @@ do_get (OtTrivialHttpd *self,
buffer = soup_buffer_new_with_owner (g_mapped_file_get_contents (mapping),
buffer_length,
mapping, (GDestroyNotify)g_mapped_file_unref);
soup_message_body_append_buffer (msg->response_body, buffer);
if (buffer->length > 0)
soup_message_body_append_buffer (msg->response_body, buffer);
soup_buffer_free (buffer);
}
else /* msg->method == SOUP_METHOD_HEAD */