1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
From bdd0e54ee303559106d2ac746f9a3d167bd89146 Mon Sep 17 00:00:00 2001
From: Kevin Funk <kfunk@kde.org>
Date: Tue, 11 Jul 2017 03:03:21 +0200
Subject: mtp: Simplify code a bit
Only one branch can be taken per call, make this clear by using
if/else-if instead of a series of ifs.
---
mtp/kio_mtp.cpp | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/mtp/kio_mtp.cpp b/mtp/kio_mtp.cpp
index 0532820..9d8585f 100644
--- a/mtp/kio_mtp.cpp
+++ b/mtp/kio_mtp.cpp
@@ -593,15 +593,12 @@ void MTPSlave::copy(const QUrl &src, const QUrl &dest, int, JobFlags flags)
{
qCDebug(LOG_KIO_MTP) << src.path() << dest.path();
- // mtp:/// to mtp:///
if (src.scheme() == QLatin1String("mtp") && dest.scheme() == QLatin1String("mtp")) {
qCDebug(LOG_KIO_MTP) << "Copy on device: Not supported";
// MTP doesn't support moving files directly on the device, so we have to download and then upload...
error(ERR_UNSUPPORTED_ACTION, i18n("Cannot copy/move files on the device itself"));
- }
- // file:/// tp mtp:///
- if (src.scheme() == QLatin1String("file") && dest.scheme() == QLatin1String("mtp")) {
+ } else if (src.scheme() == QLatin1String("file") && dest.scheme() == QLatin1String("mtp")) {
int check = checkUrl(dest);
switch (check) {
case 0:
@@ -680,9 +677,7 @@ void MTPSlave::copy(const QUrl &src, const QUrl &dest, int, JobFlags flags)
}
qCDebug(LOG_KIO_MTP) << "Sent file";
- }
- // mtp:/// to file:///
- if (src.scheme() == QLatin1String("mtp") && dest.scheme() == QLatin1String("file")) {
+ } else if (src.scheme() == QLatin1String("mtp") && dest.scheme() == QLatin1String("file")) {
int check = checkUrl(src);
switch (check) {
case 0:
--
cgit v0.11.2
From f7b9b827ed7a23403913a4e356b0549d9deaf351 Mon Sep 17 00:00:00 2001
From: Kevin Funk <kfunk@kde.org>
Date: Tue, 11 Jul 2017 03:04:21 +0200
Subject: A couple of fixes for the MTP kio slave (2 patches)
Summary:
mtp: Simplify code a bit
Only one branch can be taken per call, make this clear by using
if/else-if instead of a series of ifs.
mtp: Don't crash if getPath returns something invalid
This happens when you try to copy a file from a device which just got
locked again (I think...)
Reviewers: elvisangelaccio
Reviewed By: elvisangelaccio
Differential Revision: https://phabricator.kde.org/D6620
---
mtp/kio_mtp.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mtp/kio_mtp.cpp b/mtp/kio_mtp.cpp
index 9d8585f..541268a 100644
--- a/mtp/kio_mtp.cpp
+++ b/mtp/kio_mtp.cpp
@@ -705,6 +705,10 @@ void MTPSlave::copy(const QUrl &src, const QUrl &dest, int, JobFlags flags)
}
QPair<void *, LIBMTP_mtpdevice_t *> pair = getPath(src.path());
+ if (!pair.first) {
+ error(ERR_COULD_NOT_READ, src.path());
+ return;
+ }
LIBMTP_mtpdevice_t *device = pair.second;
LIBMTP_file_t *source = (LIBMTP_file_t *) pair.first;
--
cgit v0.11.2
|