summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-06-11 11:06:01 +0200
committerBenjamin Otte <otte@gnome.org>2009-06-11 11:06:01 +0200
commit61fcfbd9fb9e7505f9917cc2db5665b46a90e005 (patch)
treeb105727f889c42d9a237f506454fad3b2af8f73b
parent36bd5e3846effed5fe8252ece85c93f00c3a0761 (diff)
downloadgvfs-61fcfbd9fb9e7505f9917cc2db5665b46a90e005.tar.gz
[FTP] Bug 522208 - display not available error when ...
Try to return EPERM when there's a permission problem instead of returning the default error code "Operation failed".
-rw-r--r--daemon/gvfsbackendftp.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 79f83c54..721402cc 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -526,6 +526,28 @@ do_unmount (GVfsBackend * backend,
g_vfs_job_succeeded (G_VFS_JOB (job));
}
+/* sets EPERM if file exists */
+static void
+error_550_permission (GVfsFtpTask *task, gpointer file)
+{
+ GFileInfo *info;
+
+ info = g_vfs_ftp_dir_cache_lookup_file (task->backend->dir_cache, task, file, FALSE);
+ if (info)
+ {
+ g_object_unref (info);
+ g_set_error_literal (&task->error,
+ G_IO_ERROR,
+ G_IO_ERROR_PERMISSION_DENIED,
+ _("Insufficient permissions"));
+ }
+ else
+ {
+ /* clear potential error from file lookup above */
+ g_vfs_ftp_task_clear_error (task);
+ }
+}
+
static void
error_550_exists (GVfsFtpTask *task, gpointer file)
{
@@ -593,7 +615,7 @@ do_open_for_read (GVfsBackend *backend,
GVfsBackendFtp *ftp = G_VFS_BACKEND_FTP (backend);
GVfsFtpTask task = G_VFS_FTP_TASK_INIT (ftp, G_VFS_JOB (job));
GVfsFtpFile *file;
- static const GVfsFtpErrorFunc open_read_handlers[] = { error_550_is_directory, NULL };
+ static const GVfsFtpErrorFunc open_read_handlers[] = { error_550_is_directory, error_550_permission, NULL };
g_vfs_ftp_task_open_data_connection (&task);
file = g_vfs_ftp_file_new_from_gvfs (ftp, filename);