Skip to content
Snippets Groups Projects
Commit a6d99306 authored by Benedikt Meurer's avatar Benedikt Meurer
Browse files

2005-11-14 Benedikt Meurer <benny@xfce.org>

	* thunar-vfs/thunar-vfs-xfer.c: Return G_FILE_ERROR_INTR when the copy
	  operation is explicitly cancelled by the user.
	* thunar-vfs/thunar-vfs-transfer-job.c
	  (thunar_vfs_transfer_job_copy_pair): Don't delete the source file when
	  moving unless the target file was written successfully and the job
	  wasn't cancelled. This fixes a bug reported by Jari Rahkonen.




(Old svn revision: 18850)
parent f277257a
No related branches found
No related tags found
No related merge requests found
2005-11-14 Benedikt Meurer <benny@xfce.org>
* thunar-vfs/thunar-vfs-xfer.c: Return G_FILE_ERROR_INTR when the copy
operation is explicitly cancelled by the user.
* thunar-vfs/thunar-vfs-transfer-job.c
(thunar_vfs_transfer_job_copy_pair): Don't delete the source file when
moving unless the target file was written successfully and the job
wasn't cancelled. This fixes a bug reported by Jari Rahkonen.
2005-11-14 Benedikt Meurer <benny@xfce.org>
* thunar/thunar-standard-view.{c,h}: Register "Delete" as key binding
......
......@@ -620,6 +620,13 @@ thunar_vfs_transfer_job_copy_pair (ThunarVfsTransferJob *transfer_job,
break;
}
/* G_FILE_ERROR_INTR is returned when the job is cancelled during the copy operation */
if (G_UNLIKELY (error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_INTR))
{
g_error_free (error);
break;
}
/* check the error */
if (error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_EXIST)
{
......@@ -639,7 +646,6 @@ thunar_vfs_transfer_job_copy_pair (ThunarVfsTransferJob *transfer_job,
_("Unable to remove `%s': %s"), display_name,
g_strerror (errno));
skip = thunar_vfs_transfer_job_skip (transfer_job, error);
g_clear_error (&error);
g_free (display_name);
}
g_free (absolute_path);
......@@ -649,9 +655,11 @@ thunar_vfs_transfer_job_copy_pair (ThunarVfsTransferJob *transfer_job,
{
/* ask the user whether to skip this pair */
skip = thunar_vfs_transfer_job_skip (transfer_job, error);
g_clear_error (&error);
}
/* clear the error */
g_clear_error (&error);
/* check if we should skip this pair */
if (G_LIKELY (skip))
{
......
......@@ -342,6 +342,10 @@ thunar_vfs_xfer_copy_regular (const gchar *source_absolute_path,
n = read (source_fd, buffer, bufsize);
if (G_UNLIKELY (n < 0))
{
/* just try again on EAGAIN/EINTR */
if (G_UNLIKELY (errno == EAGAIN || errno == EINTR))
continue;
tvxc_set_error_from_errno (error, _("Failed to read data from `%s'"), source_absolute_path);
goto end2;
}
......@@ -349,14 +353,23 @@ thunar_vfs_xfer_copy_regular (const gchar *source_absolute_path,
break;
/* write the data to the target file */
for (m = 0; m < n; m += l)
for (m = 0; m < n; )
{
l = write (target_fd, buffer + m, n - m);
if (G_UNLIKELY (l < 0))
{
/* just try again on EAGAIN/EINTR */
if (G_UNLIKELY (errno == EAGAIN || errno == EINTR))
continue;
tvxc_set_error_from_errno (error, _("Failed to write data to `%s'"), target_absolute_path);
goto end2;
}
else
{
/* advance the offset */
m += l;
}
}
/* advance the byte offset */
......@@ -372,8 +385,9 @@ thunar_vfs_xfer_copy_regular (const gchar *source_absolute_path,
goto end2;
}
/* cancel the copy operation */
break;
/* tell the caller that the job was cancelled */
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_INTR, _("Operation cancelled"));
goto end2;
}
}
......@@ -560,6 +574,10 @@ thunar_vfs_xfer_link_internal (const ThunarVfsPath *source_path,
* free the object using thunar_vfs_path_unref(). @target_path_return
* will only be set if %TRUE is returned.
*
* As a special case, if @callback returns %FALSE (which means the
* operation should be cancelled), this method returns %FALSE and
* @error is set to #G_FILE_ERROR_INTR.
*
* Return value: %FALSE if @error is set, else %TRUE.
**/
gboolean
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment