diff options
author | Rok Mandeljc <rok.mandeljc@gmail.com> | 2014-08-04 21:15:33 +0200 |
---|---|---|
committer | Philip Langdale <philipl@overt.org> | 2014-08-04 19:53:16 -0700 |
commit | 4fff3674b9c909a5d2838bdbc96ba98724d10d56 (patch) | |
tree | 75ed38026897396a09b8d080ab7bee9c4a5ec41b | |
parent | e949e7b9918c5867a2948eb6c641171bae4e99f8 (diff) | |
download | gvfs-4fff3674b9c909a5d2838bdbc96ba98724d10d56.tar.gz |
mtp: do_open_for_read() should fail on a directory
This is a fix for bug #729628: the GIO open-read-write-close
fallback for copy/move operation on MTP volumes works correctly
for files, but fails for directories - in particular, it creates
a file with the destination name, then fails with "libmtp error:
Unknown error." This happens because the fallback first attempts
to open the source as a file, and if it succeeds, proceeds to
create destination file and copy the contents via series of
reads/writes.
For directories, do_open_for_read() should fail with
G_IO_ERROR_IS_DIRECTORY, which in tun causes GIO to create the
destination as directory, and then copy its contents over.
Signed-off-by: Rok Mandeljc <rok.mandeljc@gmail.com>
-rw-r--r-- | daemon/gvfsbackendmtp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c index 4d5cbf89..92c6d877 100644 --- a/daemon/gvfsbackendmtp.c +++ b/daemon/gvfsbackendmtp.c @@ -1921,6 +1921,14 @@ do_open_for_read (GVfsBackend *backend, goto exit; } + if (file->filetype == LIBMTP_FILETYPE_FOLDER) { + LIBMTP_destroy_file_t (file); + g_vfs_job_failed_literal (G_VFS_JOB (job), + G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY, + _("Can't open directory")); + goto exit; + } + RWHandle *handle = g_new0(RWHandle, 1); handle->handle_type = HANDLE_FILE; handle->id = entry->id; |