diff options
author | Benjamin Otte <otte@gnome.org> | 2009-06-11 11:17:41 +0200 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2009-06-11 11:17:41 +0200 |
commit | a1fdb3ff05aa8731d82f82f8bb508c533dd6049e (patch) | |
tree | 66f3c101f1ba9d8792bd2ae9797a0940b7a84892 /daemon/gvfsbackendftp.c | |
parent | b6637656b002baed39647d6b7c66d79d6bae4ed5 (diff) | |
download | gvfs-a1fdb3ff05aa8731d82f82f8bb508c533dd6049e.tar.gz |
[FTP] improve error handling for opening files
permission handler now sets EPERM when file exists and ENOENT when it
doesn't.
Diffstat (limited to 'daemon/gvfsbackendftp.c')
-rw-r--r-- | daemon/gvfsbackendftp.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c index 721402cc..19e51980 100644 --- a/daemon/gvfsbackendftp.c +++ b/daemon/gvfsbackendftp.c @@ -526,9 +526,9 @@ do_unmount (GVfsBackend * backend, g_vfs_job_succeeded (G_VFS_JOB (job)); } -/* sets EPERM if file exists */ +/* NB: sets EPERM if file exists, ENOENT if not - an error will _always_ be set */ static void -error_550_permission (GVfsFtpTask *task, gpointer file) +error_550_permission_or_not_found (GVfsFtpTask *task, gpointer file) { GFileInfo *info; @@ -545,6 +545,10 @@ error_550_permission (GVfsFtpTask *task, gpointer file) { /* clear potential error from file lookup above */ g_vfs_ftp_task_clear_error (task); + g_set_error_literal (&task->error, + G_IO_ERROR, + G_IO_ERROR_NOT_FOUND, + _("File does not exist")); } } @@ -615,7 +619,9 @@ 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, error_550_permission, NULL }; + static const GVfsFtpErrorFunc open_read_handlers[] = { error_550_is_directory, + error_550_permission_or_not_found, + NULL }; g_vfs_ftp_task_open_data_connection (&task); file = g_vfs_ftp_file_new_from_gvfs (ftp, filename); |