Bug 343329

Summary: Remote files open up empty
Product: [Applications] kate Reporter: Martynas Stropa <martynas.stropa>
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: major CC: alain, bugs.kde, ctampak, eduard, egorov, emrecio, gregory, kde, leander-kde, lehoangphuongbg, massimiliano.torromeo, michal.humpula, stanley_87
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
URL: https://bbs.archlinux.org/viewtopic.php?id=192721
See Also: https://bugs.kde.org/show_bug.cgi?id=343752
https://bugs.kde.org/show_bug.cgi?id=343245
Latest Commit: Version Fixed In:

Description Martynas Stropa 2015-01-26 14:02:17 UTC
After starting Dolphin and logging-in to an FTP server using Kwallet, I tried editing a remote file with Kate, like I've been doing for many years now, Kate asked to migrate the kwallet to a newer version. That seemed to go smoothly, but whenever a remote file is loaded it is displayed empty. I've tried restarting, using another FTP server, etc. Nothing helped. Is there something I need to set up first to make it work or something? There are no errors or warnings. I'm using Arch Linux x64.
Kate version: 5.0.0


Also, what I noticed is that when opening a remote file, temporary file in /tmp is created like "katepartTJ3018.php" and alongside "katepartTJ3018.php.part". The .part file has all the needed contents in it, however the non .part file stays empty.

Saving an opened remote file works file and file gets uploaded.

Reproducible: Always

Steps to Reproduce:
1. Open Dolphin
2. Navigate to FTP server
3. Open file

Actual Results:  
Files is opened empty

Expected Results:  
File opened with actual file content

Tmmporary file in /tmp is created like "katepartTJ3018.php" and alongside "katepartTJ3018.php.part". The .part file has all the needed contents in it, however the non .part file stays empty.
Comment 1 Martynas Stropa 2015-01-26 14:04:24 UTC
kdesdk-kioslaves 14.12.1-1 and kio-extras 5.1.2-1 installed.
Comment 2 Boris Egorov 2015-02-12 03:47:05 UTC
I can't reproduce it. I've successfully opened a few files on GNU FTP (ftp://ftp.gnu.org/) server in Dolphin (README, welcome.msg).
Comment 3 Alain Laporte 2015-02-12 09:37:37 UTC
Tested with a text file on a FTP server (vsftpd) : it doesn't work with Kate and KWrite, but I can open this remote file with Okular.
Comment 4 Michal Humpula 2015-02-15 12:03:56 UTC
As far as I know, the okular is still kde4 based. It might be some issue with kio/kio_ftp for KF5. I can replicate the issue even with the raw kioexec client:

```
lib/x86_64-linux-gnu/libexec/kf5/kioexec cat ftp://ftp.gnu.org/README
```
Comment 5 Alain Laporte 2015-02-15 12:33:15 UTC
Like Michal, I try this command :

alain@Ordi:~$/usr/lib/kf5/kioexec cat ftp://ftp.gnu.org/README
QCommandLineParser: option not defined: "suggestedfilename"
command= "cat" args= ("cat", "ftp://ftp.gnu.org/README")
kf5.kjobwidgets: kuiserver found
Copying  QUrl( "ftp://ftp.gnu.org/README" )   to  QUrl( "file:///home/alain/.cache/kioexec/krun/6890_0_README" ) 
kf5.kservice.sycoca: Trying to open ksycoca from "/home/alain/.cache/ksycoca5"
Calling notify on "Sound"
Changing audio state from  Phonon::LoadingState  to  Phonon::StoppedState 
Calling notify on "Taskbar"
0 60817413
Changing audio state from  Phonon::LoadingState  to  Phonon::StoppedState 
Changing audio state from  Phonon::StoppedState  to  Phonon::PausedState 
Changing audio state from  Phonon::PausedState  to  Phonon::PlayingState 
Changing audio state from  Phonon::PlayingState  to  Phonon::StoppedState 
Closing notification 1
not found dbus id to close 1
All files downloaded, will call slotRunApp shortly
No files downloaded -> exiting

A popup window appear with this error message : "Could not write to /home/alain/.cache/kioexec/krun/6890_0_README."

The directory /home/alain/.cache/kioexec/krun/ is missing, I create it. And I try again. A new popup window appear with this error message : "Could not rename partial file /home/alain/.cache/kioexec/krun/6537_0_README.
Please check permissions."

I set permissions of /home/alain/.cache/kioexec and /home/alain/.cache/kioexec/krun to 777 and the same error message appear.

I remove /home/alain/.cache/kioexec directory and I try with HTTP and I was this error message : "Access denied.
Could not write to /home/alain/.cache/kioexec/krun/7840_0_.part."

I create /home/alain/.cache/kioexec/krun without specific permission and it works well :

alain@Ordi:~$/usr/lib/kf5/kioexec cat http://example.com
QCommandLineParser: option not defined: "suggestedfilename"
command= "cat" args= ("cat", "http://example.com")
kf5.kjobwidgets: kuiserver found
kf5.kservice.sycoca: Trying to open ksycoca from "/home/alain/.cache/ksycoca5"
Copying  QUrl( "http://example.com/" )   to  QUrl( "file:///home/alain/.cache/kioexec/krun/7599_0_" ) 
All files downloaded, will call slotRunApp shortly
EXEC  "/usr/bin/cat /home/alain/.cache/kioexec/krun/7599_0_"
<!doctype html>
<html>
<head>
    <title>Example Domain</title>
[...]
</html>
EXEC done
sleeping...
^C

It works well with "/usr/lib/kde4/libexec/kioexec cat ftp://ftp.gnu.org/README".
Comment 6 Lê Hoàng Phương 2015-03-09 02:29:03 UTC
My error is a different to the case above. The message is:

/home/herop/.cache/kioexec/krun/8682_0_README is a folder, but a file was expected.

I have a look at the krun folder and indeed, the 8682_0_README is a folder instead of a file. Here is the log:

QCommandLineParser: option not defined: "suggestedfilename"
command= "cat" args= ("cat", "ftp://ftp.gnu.org/README")
kf5.kjobwidgets: kuiserver found
kf5.kiconthemes: "Theme tree: (Breeze)"
Copying  QUrl( "ftp://ftp.gnu.org/README" )   to  QUrl( "file:///home/herop/.cache/kioexec/krun/8682_0_README" ) 
kf5.kservice.sycoca: Trying to open ksycoca from "/home/herop/.cache/ksycoca5"
Calling notify on "Sound"
Changing audio state from  Phonon::LoadingState  to  Phonon::StoppedState 
Calling notify on "Taskbar"
0 153092101
Changing audio state from  Phonon::LoadingState  to  Phonon::StoppedState 
Changing audio state from  Phonon::StoppedState  to  Phonon::PausedState 
Changing audio state from  Phonon::PausedState  to  Phonon::PlayingState 
Changing audio state from  Phonon::PlayingState  to  Phonon::StoppedState 
Closing notification 1
not found dbus id to close 1
All files downloaded, will call slotRunApp shortly
No files downloaded -> exiting
QCoreApplication::postEvent: Unexpected null receiver
Comment 7 Tilman Klaeger 2015-04-03 12:54:39 UTC
Another confirmation for this bug from my site, using Arch Linux with latest (Kate 5.0.0, packet kate-14.12.3-1, Frameworks 5.8.0, QT 5.4.1) from Testing repo.

Trying with kioexec I get the error as described in #6 with "is a folder instead of a file".

While it is not possible to edit files over FTP there is no problem with files 
over sftp! So it seems no generall problem with remote files but with ftp.

Another finding: I monitored the server logs while opening the file and the file is actually transfered, but not displayed. Opening the file directly in Kate (Using open file, navigate to ftp://server) has the same effect.
Comment 8 Smittie 2015-04-27 18:55:58 UTC
Kubunta 15.04 (KDE 5.9.0, Kate 5.0.0), I am seeing this issue. Open remote directory via FTP (shared web hosting service), attempt to open a file in the remote directory (Open with... Kate), file appears empty in the Kate window. The same file opens normally in Okular, but appears to cause an endless authentication loop in Libre.

This worked as expected in Kubuntu 14.10.
Comment 9 Gregory 2015-04-29 09:45:54 UTC
I have also Kubuntu 15.04, after updating (from 14.10) I see the same problem. (It wasn't before.)
If I open a remote FTP directory in Dolphin, then try to open a file with Kate, there is an empty page. But if I write something and save, it overwrites the remote file. So it seems, it just can't load the content, but besides it works.
If I open an SSH directory, everything works fine. So I think, the problem must be somewhere at FTP.

I installed Bluefish editor too, just for test. If I open a file from Dolphin, the same result. But if I open a file in Bluefish (File/Open URL) from ftp, then I can see the folder tree and files, and I can open and edit. But with Dolphin and Kate it were much more comfortable for me, so I hope this bug will be fixed.
Comment 10 Haris Tampakopoulos 2015-04-29 13:00:40 UTC
In my case using in my laptop also Kubuntu 15.04, after upgrading from 14.10 and in two other computers using 15.04 clean installation, I am unable to even see the remote locations added by dolphin. I have tried both ftp and sftp locations, and both have the same problem. 

If I try to open the file from dolphin, dolphin freezes and kate displays a white page as all the others mentioned before me.

For local files everything seems to work just fine.
Comment 11 Boris Egorov 2015-05-02 11:03:01 UTC
Git commit b290473167b9d0388715fffe494ee95a5c2c2851 by Boris Egorov.
Committed on 02/05/2015 at 10:47.
Pushed by egorov into branch 'master'.

Fix path for writable location for kurl (kioexec)

There was a porting issue with this code:
QStandardPaths::writableLocation do not creates a directory [1], so we
need QDir::mkpath. Commit ff412e0bd3ba54 tried to fix it, but it gone
too far: we need to create directory only up to "/krun/", strings after
that is filename. So we were creating directory instead of file,
confusing some apps. For example, kate [2].

New behavior was tested by removing CacheLocation, and it successfully
creates needed path.

    1: http://doc.qt.io/qt-5/qstandardpaths.html#writableLocation
    2: https://bugs.kde.org/show_bug.cgi?id=343329
Related: bug 342732
REVIEW: 123589
CHANGELOG: kioexec: Fixed path for writeable location for kurl

M  +3    -3    src/kioexec/main.cpp

http://commits.kde.org/kio/b290473167b9d0388715fffe494ee95a5c2c2851
Comment 12 Boris Egorov 2015-05-02 11:03:02 UTC
Git commit e5c3f7eda489ee22c2f9f266884faa43f444f03c by Boris Egorov.
Committed on 02/05/2015 at 10:47.
Pushed by egorov into branch 'master'.

ftp slave: Fix conditions for QFile::rename

QFile::rename returns true on success[1], so code should treat it
appropriately. Previously code shows an error when all worked fine.

    1: http://doc.qt.io/qt-5/qfile.html#rename
REVIEW: 123590
CHANGELOG: ftp slave: Fix conditions for QFile::rename

M  +2    -2    src/ioslaves/ftp/ftp.cpp

http://commits.kde.org/kio/e5c3f7eda489ee22c2f9f266884faa43f444f03c
Comment 13 Alain Laporte 2015-05-13 10:10:31 UTC
Fix confirmed on ArchLinux with package kio 5.10.0.

Thanks a lot!
Comment 14 Boris Egorov 2016-02-11 16:55:02 UTC
This bug appears to be fixed. Feel free to reopen this bug if you notice such behavior.