[ostree] core: Ensure file data is synced to disk when checking out via non-hardlinks
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Ensure file data is synced to disk when checking out via non-hardlinks
- Date: Fri, 12 Oct 2012 17:24:45 +0000 (UTC)
commit 238da603b8646c7cca6e27fe901c8bb478fbd928
Author: Colin Walters <walters verbum org>
Date: Fri Oct 12 13:09:10 2012 -0400
core: Ensure file data is synced to disk when checking out via non-hardlinks
Otherwise we aren't crash-safe.
src/libostree/ostree-repo.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 8fe9934..b63df8d 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -3141,12 +3141,14 @@ checkout_file_from_input (GFile *file,
xattrs = NULL;
}
+ else
+ temp_info = g_object_ref (finfo);
if (overwrite_mode == OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES)
{
- if (g_file_info_get_file_type (temp_info ? temp_info : finfo) == G_FILE_TYPE_DIRECTORY)
+ if (g_file_info_get_file_type (temp_info) == G_FILE_TYPE_DIRECTORY)
{
- if (!ostree_create_file_from_input (file, temp_info ? temp_info : finfo,
+ if (!ostree_create_file_from_input (file, temp_info,
xattrs, input,
cancellable, &temp_error))
{
@@ -3165,11 +3167,10 @@ checkout_file_from_input (GFile *file,
{
dir = g_file_get_parent (file);
if (!ostree_create_temp_file_from_input (dir, NULL, "checkout",
- temp_info ? temp_info : finfo,
- xattrs, input, &temp_file,
+ temp_info, xattrs, input, &temp_file,
cancellable, error))
goto out;
-
+
if (rename (ot_gfile_get_path_cached (temp_file), ot_gfile_get_path_cached (file)) < 0)
{
ot_util_set_error_from_errno (error, errno);
@@ -3179,11 +3180,17 @@ checkout_file_from_input (GFile *file,
}
else
{
- if (!ostree_create_file_from_input (file, temp_info ? temp_info : finfo,
+ if (!ostree_create_file_from_input (file, temp_info,
xattrs, input, cancellable, error))
goto out;
}
+ if (g_file_info_get_file_type (temp_info) == G_FILE_TYPE_REGULAR)
+ {
+ if (!ensure_file_data_synced (file, cancellable, error))
+ goto out;
+ }
+
ret = TRUE;
out:
return ret;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]