From 5f716701ded601f0f63211b57d936ab02433ff48 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Fri, 2 Jul 2021 16:11:55 +0900 Subject: [PATCH 1/2] Keep modified time of the file copied from foreign location Related: issue_218 Copy G_FILE_ATTRIBUTE_TIME_MODIFIED after copying file contents --- thunar/thunar-transfer-job.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/thunar/thunar-transfer-job.c b/thunar/thunar-transfer-job.c index 2c8329288..d7fd6e525 100644 --- a/thunar/thunar-transfer-job.c +++ b/thunar/thunar-transfer-job.c @@ -411,10 +411,11 @@ ttj_copy_file (ThunarTransferJob *job, gboolean merge_directories, GError **error) { - GFileType source_type; - GFileType target_type; - gboolean target_exists; - GError *err = NULL; + GFileInfo *info; + GFileType source_type; + GFileType target_type; + gboolean target_exists; + GError *err = NULL; _thunar_return_val_if_fail (THUNAR_IS_TRANSFER_JOB (job), FALSE); _thunar_return_val_if_fail (G_IS_FILE (source_file), FALSE); @@ -458,6 +459,16 @@ ttj_copy_file (ThunarTransferJob *job, exo_job_get_cancellable (EXO_JOB (job)), thunar_transfer_job_progress, job, &err); + if (G_UNLIKELY (err == NULL && !g_file_is_native (source_file))) + { + info = g_file_query_info (source_file, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, + exo_job_get_cancellable (EXO_JOB (job)), &err); + + g_file_set_attributes_from_info (target_file, info, G_FILE_QUERY_INFO_NONE, + exo_job_get_cancellable (EXO_JOB (job)), &err); + g_clear_object (&info); + } + /* check if there were errors */ if (G_UNLIKELY (err != NULL && err->domain == G_IO_ERROR)) { -- GitLab From 6deea6f51ea0e3ff576fe7a5e6bd54546d398c38 Mon Sep 17 00:00:00 2001 From: "mshrimp@sogang.ac.kr" Date: Tue, 6 Jul 2021 06:52:07 +0900 Subject: [PATCH 2/2] Leave memo --- thunar/thunar-transfer-job.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/thunar/thunar-transfer-job.c b/thunar/thunar-transfer-job.c index d7fd6e525..5baa48bfd 100644 --- a/thunar/thunar-transfer-job.c +++ b/thunar/thunar-transfer-job.c @@ -459,6 +459,16 @@ ttj_copy_file (ThunarTransferJob *job, exo_job_get_cancellable (EXO_JOB (job)), thunar_transfer_job_progress, job, &err); + /** + * MR !127 notes: + * (Discusssion: https://gitlab.xfce.org/xfce/thunar/-/merge_requests/127) + * + * Proper solution for copying lost metadata requires + * `g_file_build_attribute_list_for_copy`, which is + * added in Glib 2.68 (which is too recent a version + * to add for now) so we leave a comment here. Patch + * this when 2.68 is ready. + **/ if (G_UNLIKELY (err == NULL && !g_file_is_native (source_file))) { info = g_file_query_info (source_file, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, -- GitLab