[gvfs] MTP: Handle overwriting of files in do_push correctly.
- From: Philip Langdale <philipl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] MTP: Handle overwriting of files in do_push correctly.
- Date: Sat, 30 Mar 2013 23:27:05 +0000 (UTC)
commit d31ebff2b2d9a44f380ada8887c77dfdee770eb5
Author: Philip Langdale <philipl overt org>
Date: Wed Mar 20 09:11:14 2013 -0700
MTP: Handle overwriting of files in do_push correctly.
If a file copy is requested without OVERWRITE but the destination
exists, return G_IO_ERROR_EXISTS. If OVERWRITE is requested, then
delete the destination before the push.
https://bugzilla.gnome.org/show_bug.cgi?id=696163
daemon/gvfsbackendmtp.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index 212aff6..ba260b6 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -1513,7 +1513,29 @@ do_push (GVfsBackend *backend,
LIBMTP_mtpdevice_t *device;
device = G_VFS_BACKEND_MTP (backend)->device;
- CacheEntry *entry = get_cache_entry (G_VFS_BACKEND_MTP (backend), dir_name);
+ CacheEntry *entry = get_cache_entry (G_VFS_BACKEND_MTP (backend), destination);
+ if (entry != NULL && entry->id != -1) {
+ if (flags & G_FILE_COPY_OVERWRITE) {
+ DEBUG ("(I) Removing destination.");
+ int ret = LIBMTP_Delete_Object (device, entry->id);
+ if (ret != 0) {
+ fail_job (G_VFS_JOB (job), device);
+ goto exit;
+ }
+ g_hash_table_foreach (G_VFS_BACKEND_MTP (backend)->monitors,
+ emit_delete_event,
+ (char *)destination);
+ remove_cache_entry (G_VFS_BACKEND_MTP (backend),
+ destination);
+ } else {
+ g_vfs_job_failed_literal (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_EXISTS,
+ _("File already exists"));
+ goto exit;
+ }
+ }
+
+ entry = get_cache_entry (G_VFS_BACKEND_MTP (backend), dir_name);
if (!entry) {
g_vfs_job_failed_literal (G_VFS_JOB (job),
G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]