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