summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2014-09-11 08:55:21 +0200
committerOndrej Holy <oholy@redhat.com>2014-12-03 09:25:15 +0100
commit4cff08d1d9c458eb3ee46a4c4326626fffcaa7a8 (patch)
tree04622d4663ce799094494ba8d1f1a25a7965c7b1
parent643498c51747d2b0ff2290352afdac97a9771e02 (diff)
downloadgvfs-4cff08d1d9c458eb3ee46a4c4326626fffcaa7a8.tar.gz
gvfsjobunmount: don't unmount if dialog was cancelled
If the dialog about blocking processes was cancelled, G_IO_ERROR_FAILED_HANDLED will be returned and backend won't be unmounted. https://bugzilla.gnome.org/show_bug.cgi?id=710986
-rw-r--r--daemon/gvfsbackend.c25
-rw-r--r--daemon/gvfsbackend.h3
-rw-r--r--daemon/gvfsjobunmount.c14
3 files changed, 30 insertions, 12 deletions
diff --git a/daemon/gvfsbackend.c b/daemon/gvfsbackend.c
index ac84e356..e679e30d 100644
--- a/daemon/gvfsbackend.c
+++ b/daemon/gvfsbackend.c
@@ -811,22 +811,29 @@ complete_unmount_with_op (UnmountWithOpData *data)
ret = TRUE;
+ simple = g_simple_async_result_new (G_OBJECT (data->backend),
+ data->callback,
+ data->user_data,
+ NULL);
+
if (data->no_more_processes)
{
/* do nothing, e.g. return TRUE to signal we should unmount */
}
+ else if (!data->ret)
+ {
+ /* "show-processes" signal wasn't handled, return TRUE to signal we should unmount */
+ }
else
{
if (data->aborted || data->choice == 1)
{
+ g_simple_async_result_set_error (simple, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED,
+ "GMountOperation aborted");
ret = FALSE;
}
}
- simple = g_simple_async_result_new (G_OBJECT (data->backend),
- data->callback,
- data->user_data,
- NULL);
g_simple_async_result_set_op_res_gboolean (simple, ret);
g_simple_async_result_complete (simple);
g_object_unref (simple);
@@ -894,22 +901,26 @@ unmount_with_op_data_free (UnmountWithOpData *data)
* @backend: A #GVfsBackend.
* @res: A #GAsyncResult obtained from the @callback function passed
* to g_vfs_backend_unmount_with_operation().
+ * @error: A #GError, or NULL.
*
* Gets the result of the operation started by
* gvfs_backend_unmount_with_operation_sync().
*
+ * If the operation was cancelled, G_IO_ERROR_FAILED_HANDLED will be returned.
+ *
* Returns: %TRUE if the backend should be unmounted (either no blocking
* processes or the user decided to unmount anyway), %FALSE if
- * no action should be taken.
+ * no action should be taken (error is set).
*/
gboolean
g_vfs_backend_unmount_with_operation_finish (GVfsBackend *backend,
- GAsyncResult *res)
+ GAsyncResult *res,
+ GError **error)
{
gboolean ret;
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, NULL))
+ if (g_simple_async_result_propagate_error (simple, error))
{
ret = FALSE;
}
diff --git a/daemon/gvfsbackend.h b/daemon/gvfsbackend.h
index 1669c27c..6f77cf9c 100644
--- a/daemon/gvfsbackend.h
+++ b/daemon/gvfsbackend.h
@@ -516,7 +516,8 @@ void g_vfs_backend_set_block_requests (GVfsBackend
gboolean g_vfs_backend_get_block_requests (GVfsBackend *backend);
gboolean g_vfs_backend_unmount_with_operation_finish (GVfsBackend *backend,
- GAsyncResult *res);
+ GAsyncResult *res,
+ GError **error);
void g_vfs_backend_unmount_with_operation (GVfsBackend *backend,
GMountSource *mount_source,
diff --git a/daemon/gvfsjobunmount.c b/daemon/gvfsjobunmount.c
index 2108ddf8..0cc6934e 100644
--- a/daemon/gvfsjobunmount.c
+++ b/daemon/gvfsjobunmount.c
@@ -210,13 +210,19 @@ unmount_cb (GVfsBackend *backend,
GVfsBackendClass *class = G_VFS_BACKEND_GET_CLASS (op_job->backend);
gboolean should_unmount;
gboolean finished;
+ GError *error = NULL;
should_unmount = g_vfs_backend_unmount_with_operation_finish (backend,
- res);
-
- if (should_unmount)
- op_job->flags |= G_MOUNT_UNMOUNT_FORCE;
+ res,
+ &error);
+ if (!should_unmount)
+ {
+ g_vfs_job_failed_from_error (G_VFS_JOB (op_job), error);
+ g_error_free (error);
+ return;
+ }
+ op_job->flags |= G_MOUNT_UNMOUNT_FORCE;
finished = job_finish_immediately_if_possible (op_job);
if (! finished)