Bug 255296

Summary: Moving files on sftp which overwrites other files does not work
Product: kio Reporter: Ralf Jung <post>
Component: sftpAssignee: Andreas Schneider <asn>
Status: RESOLVED FIXED    
Severity: normal CC: adawit
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu Packages   
OS: Linux   
Latest Commit: Version Fixed In: 4.6.4
Attachments: kiosftp log

Description Ralf Jung 2010-10-26 11:09:50 UTC
Version:           unspecified (using KDE 4.5.1) 
OS:                Linux



Reproducible: Always

Steps to Reproduce:
On some SFTP folder, select a file, hit Ctrl+X, then go somewhere else where a file with the same name exists, and hit Ctrl+V.

Actual Results:  
After confirming I want to overwrite the file, I get an error: "The folder or file <destination file name> does not exist".

Expected Results:  
The file should be moved and the original file overwritten.
Comment 1 Ralf Jung 2011-04-18 22:04:56 UTC
I just updated to KDE 4.6, and this issue is unfortunately still around.
Comment 2 Andreas Schneider 2011-04-18 22:58:23 UTC
Which version of 4.6?
Comment 3 Ralf Jung 2011-04-19 10:06:03 UTC
4.6.2 from the Kubuntu backports PPA.
Comment 4 Andreas Schneider 2011-05-01 12:21:08 UTC
I have to test this, but I think this is a KIO issue. It should download the file and upload it again. This doesn't happen.

Could you provide log files please.

http://techbase.kde.org/Development/Tutorials/Debugging/Debugging_IOSlaves/Debugging_kio_sftp
Comment 5 Ralf Jung 2011-05-01 12:34:10 UTC
Actually I do not think it should download and re-upload the file - for example, on ftp, I can move a file that is several 100 MiB or even bigger in size without any delay. A re-upload would take a loooong time.
I should also mention that copying a file that overwrites another works fine (i.e., replace "Ctrl+X by "Ctrl+C" in he steps above). Just moving is a problem.

I enabled the logging and got a rather large file containing a whole lot of folder names of the university server and whatnot - I don't want to upload it all here, but I think I found the right part and attached it. If this is not enough, I can email you a more complete logfile.
Comment 6 Ralf Jung 2011-05-01 12:34:36 UTC
Created attachment 59483 [details]
kiosftp log
Comment 7 Andreas Schneider 2011-05-01 14:34:11 UTC
SFTP doesn't support server side copying of files. So you can only download and then upload it to the new location.

However, looking at the log file. The file is correctly renamed/moved to its new location but then KIO tries to delete the old file and fails cause the file doesn't exist anymore.
Comment 8 Andreas Schneider 2011-05-03 16:00:38 UTC
Dawit, this looks like a KIO issue and not sftp related but I'm not 100% sure. Could you please comment?
Comment 9 Dawit Alemayehu 2011-05-03 19:09:40 UTC
(In reply to comment #8)
> Dawit, this looks like a KIO issue and not sftp related but I'm not 100% sure.
> Could you please comment?

Yeah to me this seems to be a KIO::CopyJob issue. Specifically, when you choose to move a file, whether through Cut+Paste or Drag&Drop+Move, if the file you are moving already exists in the destination and you choose to overwrite it, KIO::CopyJob does not send a rename command with the overwrite flag set to true. Instead it attempts to do something I do not quite comprhend ; so this is a question for David to answer. CC'ing him.
Comment 10 Dawit Alemayehu 2011-05-03 19:38:51 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > Dawit, this looks like a KIO issue and not sftp related but I'm not 100% sure.
> > Could you please comment?
> 
> Yeah to me this seems to be a KIO::CopyJob issue. Specifically, when you choose
> to move a file, whether through Cut+Paste or Drag&Drop+Move, if the file you
> are moving already exists in the destination and you choose to overwrite it,
> KIO::CopyJob does not send a rename command with the overwrite flag set to
> true. Instead it attempts to do something I do not quite comprhend ; so this is
> a question for David to answer. CC'ing him.

Actually I take it back. KIO::CopyJob does do the right thing and sends a second rename command with the overwrite flag set to true. Actually, it is kio_sftp's rename function calling its "del" function to remove the desintation that is causing this problem ; so this is a kio_sftp bug. Removing David from the CC list.
Comment 11 Dawit Alemayehu 2011-05-03 20:32:36 UTC
Git commit 39b75552f89e6eef6e6ad6c637dc4663d58facd9 by Dawit Alemayehu.
Committed on 03/05/2011 at 20:01.
Pushed by adawit into branch 'KDE/4.6'.

Don't call del when asked to overwrite a destination file in rename. Otherwise,
the finished signal from calling del will cause the bug reported in 255296.

BUG: 255296
FIXED-IN: 4.6.4

M  +13   -2    kioslave/sftp/kio_sftp.cpp     

http://commits.kde.org/kde-runtime/39b75552f89e6eef6e6ad6c637dc4663d58facd9
Comment 12 Dawit Alemayehu 2011-05-03 20:32:46 UTC
Git commit b7e73614d258b37eeb4ebf2758fb96bb2f8b2526 by Dawit Alemayehu.
Committed on 03/05/2011 at 20:01.
Pushed by adawit into branch 'master'.

Don't call del when asked to overwrite a destination file in rename. Otherwise,
the finished signal from calling del will cause the bug reported in 255296.

CCBUG: 255296

(cherry picked from commit 39b75552f89e6eef6e6ad6c637dc4663d58facd9)

M  +13   -2    kioslave/sftp/kio_sftp.cpp     

http://commits.kde.org/kde-runtime/b7e73614d258b37eeb4ebf2758fb96bb2f8b2526