Bug 353195

Summary: Copy error for folders with mixed files & folders in Split View
Product: [Frameworks and Libraries] frameworks-kio Reporter: Chuck <cfox04>
Component: generalAssignee: David Faure <faure>
Status: RESOLVED FIXED    
Severity: normal CC: 2rb0alex, andysem, cameronpoe, cesarg9, chris.rapson, cloutier.jo, cyberbeat, drajdoyle, elvis.angelaccio, emmanuelpescosta099, germano.massullo, get.sonic, hrvooje, info, just89, kde-bugs.9ek5t, kdelibs-bugs, kilbertphone, patrick.rifici, pedron.alexandre, reuben_p, rlaggren, Robert.Spillner, s, schnere, serhiy.int, setingo, simonandric5, wulf.richartz
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.22
Attachments: video showing error

Description Chuck 2015-09-25 20:09:50 UTC
When copying & pasting between panes in the split view of dolphin, I can trigger a bug when attempting to copy a mix of individual files in the top-level folder and one or more sub-folders.

For example:
Left pane:
FileA.txt
Subdir/ (with files and further subdirectories)

Right pane:
A destination directory that already has at least one of a file or subdirectory present. Typically these are *not* being overwritten by the source files.

Try to copy both the Subdir folder and the regular files to the target directory by dragging & dropping to the right pane. The following error occurs:

Error: "[pathname of source Subdir] is a folder, but a file was expected"

Note: Individual files can still be copied, but directory folders throw the error seen above.

The bug won't trigger 100% the first time, but I've noticed that once it triggers, even wiping out the target directory contents won't let me copy the subfolder over.  Additionally, for whatever reason I can't make the bug trigger when doing the same operation between completely separate Dolphin windows, at least for me it only occurs between panes in split-view (maybe you can make it trigger under different circumstances).


Reproducible: Sometimes


Actual Results:  
Error message that program was expecting a file and got a directory. Copy operation does not occur.

Expected Results:  
Copy the folder over correctly and do not produce an error message.

This is Dolphin 15.08.1 under KDE Frameworks 5.14 Plasma 5.4.1 with Qt 5.5 on Arch Linux. The automatic bug report doesn't let me select the correct version.
Comment 1 Emmanuel Pescosta 2015-10-15 19:19:42 UTC
Thanks for the bug report!

> Error: "[pathname of source Subdir] is a folder, but a file was expected" Note: 
> Individual files can still be copied, but directory folders throw the error seen abov

Dolphin uses KIO to copy files, I'll reassign it to KIO.
Comment 2 David Faure 2015-10-17 12:28:20 UTC
Emmanuel, which KIO method is being called in such a case?

This error sounds like KIO::file_copy is called instead of KIO::copy, possibly.

Either that there's a porting bug in KIO, of course.
Comment 3 Germano Massullo 2015-12-01 14:02:22 UTC
You can mark as confirmed since there are many affected people, included me
Comment 4 Germano Massullo 2015-12-01 14:03:26 UTC
plasma-desktop-5.4.3-1.fc23.x86_64
kf5-kio-core-5.16.0-2.fc23.x86_64
Comment 5 David Faure 2015-12-14 08:21:26 UTC
I need more step-by-step instructions to reproduce the bug reliably.
I tried a number of variants of copying dir+file from left view to right view (using DnD and then choosing Copy in the popupmenu), no error occured. There must be something more specific to trigger the bug...
Comment 6 Cyril Brosch 2015-12-14 09:49:08 UTC
It is extremely hard to reproduce, for me it seems to happen simply from time to time. 
I've just tested many copy situations, and when I finally got the error (I deleted a folder, and then copied another folder from the same directory), I could not reproduce it later after restart of dolphin, doing exactly the same actions.
Comment 7 Cesar Garcia 2015-12-20 06:02:35 UTC
I can reproduce the bug everytime with both sftp and smb connections in one of the panes.

This is what i do:

* Open split view
* Open a network connection in one of the panes, for example a smb shared folder or just sftp://localhost/some_folder
* Create a new folder in the local view using any name.
* Create a file (or use an existing one) and move/copy it to the newly created folder.
* Drag the folder to the smb/sftp pane and choose copy/move.

Basically the trigger is to copy/move a file to a folder in one pane before moving that folder to the other pane.
Comment 8 Wulf 2015-12-21 22:40:48 UTC
happens to me, when I try to copy to a mounted NTFS USB-Drive
Comment 9 rlaggren 2015-12-28 17:18:39 UTC
Happens w/in same Dolphin window. Copy dir from tree in home directory (using mouse/context menu) paste by rt-clk on target in different part of the home/(tree). Target can be either in the folder panel or the file list pane; in the file list pane it errors regardless whether the target is a directory or if you click and past "in the field" to paste into the dir currently displayed level.  

More detail: First time I have see this; I've used Dolphin regularly w/this distro version for about 6 weeks since upgrading the distro. The dir I attempt to copy contains only files (no dirs) - 800+ jpg's, about 69MB total. I had just created the source dir (a dir for working purposes) on the tree and pasted the files into it in one batch from my dl dir (where the files comprised the total contents of that dl dir and I selected all of them at once) using rt-clk/cut and then rt-clk/paste to the list pane of the newly created working dir. So far good. I then  was attempting to copy that working dir and paste it into another folder for backup purposes and got the error.

Suse LEAP 42.1 (upgraded from suse 12.2)
Kde et al,  is standard distro install
Comment 10 Wulf 2015-12-28 19:49:41 UTC
I can't reproduce it anymore :-?

What I did besides installing and updating a lot of stuff: I deleted ~/.config/mimeapps.list and ~/.local/share/applications/mimeapps.list with a lot of xfce-garbage in it
Comment 11 Wulf 2016-01-05 19:23:10 UTC
(In reply to Wulf from comment #10)
> I can't reproduce it anymore :-?
Sorry wrong.

It' reproducible
- two panes (one pane is my external NTFS USB Drive)
- in the other pane a folder with two different kinds of files (media and text)
- you expand the this folder (you don not change into this folder)
- you move the text file to trash
- you try to copy the folder (now with only one expanded media-file) per drag and drop to the external pane
- error occurs
Comment 12 kilbertphone 2016-01-14 22:44:31 UTC
Created attachment 96647 [details]
video showing error

video showing how to reproduce error
Comment 13 kilbertphone 2016-01-14 22:45:31 UTC
error: "is a folder but a file was expected"
I can reproduce when moving large files (or groups) if:
Using Dolphin (v15.12.0) split window, copying a file.

From left side window, copy to right side a large file(or group) that does not exist.
then while that is copying, load a different drive/location in the original left side of window. (file is still copying)
When notification of copy is complete, take now completed file from right side. and try to copy to left (where the new location is) and then the error occurs.

error pops up "xxxxx.xxx is a folder but a file was expected"

KDE openSUSE Leap 42.1
Comment 14 Syam 2016-01-17 06:05:26 UTC
I hit this bug while doing something exactly as described in comment #13.
Fedora 23 x86-64, 
Dolphin Version 15.08.1
KDE Frameworks 5.18.0
Qt 5.5.1 (built against 5.5.1)
Comment 15 s 2016-03-10 09:22:11 UTC
I have the same Problem: Copy a folder from local drive to sftp. Opening two windows works fine! Only the splitview has a problem.

Using:
Ubuntu 15.10
Dolphin Version 15.08.2
KDE Frameworks 5.18.0
Qt 5.5.1 (built against 5.5.1)
Comment 16 Kai Dombrowe 2016-03-12 10:17:58 UTC
i can reproduce it without the splitview:

1. create a tmp folder
2. inside the tmp folder create two folders: a and b
4. move b inside a (dnd)
5. try to copy folder a
6. error

Opening two windows works fine

Kubuntu 15.10
Dolphin 15.08.2
KDE Frameworks 5.15.0
Qt 5.4.2, built agains 5.4.2
Comment 17 Syam 2016-03-12 13:22:26 UTC
(In reply to Kai Dombrowe from comment #16)

I can reproduce this at will on Fedora too.

Fedora 23, x86-64
Dolphin 15.12.1
KDE Frameworks 5.19.0
Qt 5.5.1 (built against 5.5.1)
Comment 18 Chuck 2016-03-12 20:24:57 UTC
I was able to reproduce the bug using Kai's tmp-folder steps.  That might be an easier way to get closer to the root cause of the bug since it is easily reproducible and only requires one dolphin pane to be open.
Comment 19 Elvis Angelaccio 2016-03-12 22:04:41 UTC
I can reproduce it as well using the steps in comment #16.
Comment 20 Kai Dombrowe 2016-03-13 02:59:50 UTC
maybe a cache bug in KCoreDirLister? :
it works if i replace (kio/src/core/copyop.cpp @ void CopyJobPrivate::statCurrentSrc())
const KFileItem cachedItem = KCoreDirLister::cachedItemForUrl(m_currentSrcURL);
with:
const KFileItem cachedItem; // Null
Comment 21 Emmanuel Pescosta 2016-03-13 11:48:22 UTC
(In reply to David Faure from comment #2)
> Emmanuel, which KIO method is being called in such a case?
> 
> This error sounds like KIO::file_copy is called instead of KIO::copy,
> possibly.
> 
> Either that there's a porting bug in KIO, of course.

KIO::paste is being called, see DolphinView::pasteToUrl.
Comment 22 Emmanuel Pescosta 2016-03-13 11:56:46 UTC
(In reply to Kai Dombrowe from comment #20)
> maybe a cache bug in KCoreDirLister? :

Thanks for debugging :)

I came to the same conclusion, but I didn't have time to further debug the caching stuff and write a test case for it.
Comment 23 hrvooje 2016-04-14 22:08:16 UTC
(In reply to Kai Dombrowe from comment #16)
> i can reproduce it without the splitview:
> 
> 1. create a tmp folder
> 2. inside the tmp folder create two folders: a and b
> 4. move b inside a (dnd)
> 5. try to copy folder a
> 6. error
> 
> Opening two windows works fine
> 
> Kubuntu 15.10
> Dolphin 15.08.2
> KDE Frameworks 5.15.0
> Qt 5.4.2, built agains 5.4.2

I can reproduce this too. It first happend to me when I tried to copy a large amount of data to smb. 7 months and still not fixed? This is important, big bug in file manager.
Comment 24 David Faure 2016-04-17 21:58:32 UTC
Git commit 4daa10cca05ccd990167581dc1d2b17c371a1384 by David Faure.
Committed on 17/04/2016 at 21:58.
Pushed by dfaure into branch 'master'.

First attempt at a unittest for bug 353195.

It passes though, so something must be missing (maybe waiting for the cache to be updated?).
To be continued.

M  +25   -0    autotests/kdirlistertest.cpp
M  +1    -0    autotests/kdirlistertest.h

http://commits.kde.org/kio/4daa10cca05ccd990167581dc1d2b17c371a1384
Comment 25 David Faure 2016-04-19 10:59:35 UTC
Got the test to work (i.e. fail) this morning. I'll finish fixing this after work.
Comment 26 David Faure 2016-04-19 20:58:25 UTC
Git commit 6005183a0af0e46b0f5ebd40eabaf343d2506ee6 by David Faure.
Committed on 19/04/2016 at 20:55.
Pushed by dfaure into branch 'master'.

Fix regression in KFileItem: refresh() would lose the file type, so a dir became a file.

Many thanks to Kai Dombrowe for the simple and fully reproduceable steps
(which are now coded in the unittest).

CCMAIL: markg85@gmail.com
Mark, this is why existing code should be refactored (i.e. moved) rather
than replaced. See also the BUG comment below, I think we have to stop using
this constructor.
FIXED-IN: 5.22

M  +8    -2    autotests/kdirlistertest.cpp
M  +11   -0    autotests/kfileitemtest.cpp
M  +1    -0    autotests/kfileitemtest.h
M  +3    -1    src/core/udsentry.cpp

http://commits.kde.org/kio/6005183a0af0e46b0f5ebd40eabaf343d2506ee6
Comment 27 David Faure 2016-04-30 08:38:22 UTC
*** Bug 355115 has been marked as a duplicate of this bug. ***
Comment 28 Elvis Angelaccio 2016-07-12 11:59:25 UTC
*** Bug 365216 has been marked as a duplicate of this bug. ***
Comment 29 Elvis Angelaccio 2016-07-12 12:01:33 UTC
*** Bug 365043 has been marked as a duplicate of this bug. ***
Comment 30 Elvis Angelaccio 2016-07-12 12:08:32 UTC
*** Bug 362840 has been marked as a duplicate of this bug. ***
Comment 31 Elvis Angelaccio 2016-12-26 14:38:00 UTC
*** Bug 357539 has been marked as a duplicate of this bug. ***
Comment 32 chris.rapson 2017-08-17 06:31:37 UTC
I just got this error message in a situation similar to comment 16. I copied a folder, changed the contents, and then tried to copy it again - all in the same parent folder. (And all in the same dolphin window with only one pane open.)

Since this was marked resolved over a year ago, am I seeing the same bug or something new? I'm running Ubuntu 16.04.2 LTS. Kernel 4.4.0-89-generic
Comment 33 Christoph Feck 2017-09-04 15:04:40 UTC
Please ask in a forum of your distribution how to install the backport PPAs with newer KDE software.