57 lines
1.8 KiB
Diff
57 lines
1.8 KiB
Diff
From 8fef6abe1131da0c8a7211c740a12ebe11cbcc51 Mon Sep 17 00:00:00 2001
|
|
From: Philip Withnall <pwithnall@endlessos.org>
|
|
Date: Wed, 10 Mar 2021 16:05:55 +0000
|
|
Subject: [PATCH 1/3] glocalfileoutputstream: Factor out a flag check
|
|
|
|
This clarifies the code a little. It introduces no functional changes.
|
|
|
|
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
|
|
---
|
|
gio/glocalfileoutputstream.c | 9 +++++----
|
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c
|
|
index 57d2d5dfe..6a70b2a04 100644
|
|
--- a/gio/glocalfileoutputstream.c
|
|
+++ b/gio/glocalfileoutputstream.c
|
|
@@ -751,6 +751,7 @@ handle_overwrite_open (const char *filename,
|
|
int res;
|
|
int mode;
|
|
int errsv;
|
|
+ gboolean replace_destination_set = (flags & G_FILE_CREATE_REPLACE_DESTINATION);
|
|
|
|
mode = mode_from_flags_or_info (flags, reference_info);
|
|
|
|
@@ -857,8 +858,8 @@ handle_overwrite_open (const char *filename,
|
|
* The second strategy consist simply in copying the old file
|
|
* to a backup file and rewrite the contents of the file.
|
|
*/
|
|
-
|
|
- if ((flags & G_FILE_CREATE_REPLACE_DESTINATION) ||
|
|
+
|
|
+ if (replace_destination_set ||
|
|
(!(original_stat.st_nlink > 1) && !is_symlink))
|
|
{
|
|
char *dirname, *tmp_filename;
|
|
@@ -877,7 +878,7 @@ handle_overwrite_open (const char *filename,
|
|
|
|
/* try to keep permissions (unless replacing) */
|
|
|
|
- if ( ! (flags & G_FILE_CREATE_REPLACE_DESTINATION) &&
|
|
+ if (!replace_destination_set &&
|
|
(
|
|
#ifdef HAVE_FCHOWN
|
|
fchown (tmpfd, original_stat.st_uid, original_stat.st_gid) == -1 ||
|
|
@@ -1016,7 +1017,7 @@ handle_overwrite_open (const char *filename,
|
|
}
|
|
}
|
|
|
|
- if (flags & G_FILE_CREATE_REPLACE_DESTINATION)
|
|
+ if (replace_destination_set)
|
|
{
|
|
g_close (fd, NULL);
|
|
|
|
--
|
|
2.31.1
|
|
|