From 4b91a34048b046e8da9d09e1382f8a03d98ae51c Mon Sep 17 00:00:00 2001 From: Alexander Schwinn Date: Mon, 12 Aug 2019 23:55:08 +0200 Subject: [PATCH] Replacing a file via Cut and Paste in the same filesystem makes a copy - Bug #15727 --- thunar/thunar-transfer-job.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/thunar/thunar-transfer-job.c b/thunar/thunar-transfer-job.c index cfa932ad..4ea9ed0e 100644 --- a/thunar/thunar-transfer-job.c +++ b/thunar/thunar-transfer-job.c @@ -982,12 +982,13 @@ thunar_transfer_job_execute (ExoJob *job, /* update progress information */ exo_job_info_message (job, _("Trying to move \"%s\""), g_file_info_get_display_name (info)); - + printf("THUNAR_TRANSFER_JOB_MOVE\n"); if (g_file_move (node->source_file, tp->data, flags, exo_job_get_cancellable (job), NULL, NULL, &err)) { + printf("THUNAR_TRANSFER_JOB_MOVE 1.1\n"); /* notify the thumbnail cache of the move operation */ thunar_thumbnail_cache_move_file (thumbnail_cache, node->source_file, @@ -1006,6 +1007,26 @@ thunar_transfer_job_execute (ExoJob *job, } else if (!exo_job_is_cancelled (job)) { + printf("THUNAR_TRANSFER_JOB_MOVE 1.2\n"); + if( err->code == G_IO_ERROR_EXISTS ) + { + printf("Already exists\n"); + g_clear_error (&err); + response = thunar_job_ask_replace (THUNAR_JOB (job), node->source_file, tp->data, &err); + /* add overwrite flag and retry if we should overwrite */ + if (response == THUNAR_JOB_RESPONSE_YES) + { + flags |= G_FILE_COPY_OVERWRITE; + g_file_move (node->source_file, tp->data, + flags, + exo_job_get_cancellable (job), + NULL, NULL, &err); + } + +// TODO Support for other cases +// TODO Fix error(s) after move + } + g_clear_error (&err); /* update progress information */ -- 2.11.0