Bug 384500 - kioexec: Spurious prompt to re-upload, when a temporary file has been used
Summary: kioexec: Spurious prompt to re-upload, when a temporary file has been used
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-08 17:19 UTC by Jonathan Marten
Modified: 2017-09-29 19:39 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Marten 2017-09-08 17:19:17 UTC
Simple test case:  use kioclient5 to open a remote file in an application that uses %f or %F, not %u or %U, in its destop file:

$ kioclient5 exec 'smb://host/dir/test.kmz'

The file is opened in Marble as expected, which has Exec=marble %F in its desktop file.  However, a dialogue also immediately appears saying "The file has been modified, do you want to upload the changes?".

The debug log shows:

kdeinit5: Got EXEC_NEW '/usr/lib64/qt5/plugins/kf5/kio/smb.so' from launcher.
kdeinit5: preparing to launch '/usr/lib64/qt5/plugins/kf5/kio/smb.so'
smb.so(31291) SMBSlave::auth_initialize_smbc: auth_initialize_smbc 
smb.so(31291) SMBSlave::auth_initialize_smbc: smbc_init call
WARNING: Ignoring invalid value 'share' for parameter 'security'
smb.so(31291) SMBSlave::stat: QUrl("smb://host/dir/test.kmz")
smb.so(31291) SMBSlave::checkURL: checkURL  QUrl("smb://host/dir/test.kmz")
smb.so(31291) SMBSlave::checkURL: checkURL return3  QUrl("smb://host/dir/test.kmz")
smb.so(31291) SMBUrl::updateCache: updateCache  "/dir/test.kmz"
smb.so(31291) SMBSlave::cache_stat: size  19570320
smb.so(31291) SMBUrl::updateCache: updateCache  "/dir/test.kmz"
smb.so(31291) SMBSlave::stat: QUrl("smb://host/dir/test.kmz")
smb.so(31291) SMBSlave::checkURL: checkURL  QUrl("smb://host/dir/test.kmz")
smb.so(31291) SMBSlave::checkURL: checkURL return3  QUrl("smb://host/dir/test.kmz")
smb.so(31291) SMBUrl::updateCache: updateCache  "/dir/test.kmz"
smb.so(31291) SMBSlave::cache_stat: size  515
kdeinit5: Got EXT_EXEC '/usr/lib64/libexec/kf5/kioexec' from launcher.
kdeinit5: preparing to launch '/usr/lib64/libexec/kf5/kioexec'
kioexec(31295) KIOExec::KIOExec: command= "marble %F" args= ("marble %F", "smb://host/dir/test.kmz")
kdeinit5: Got EXEC_NEW '/usr/lib64/qt5/plugins/kf5/kio/smb.so' from launcher.
kdeinit5: preparing to launch '/usr/lib64/qt5/plugins/kf5/kio/smb.so'
WARNING: Ignoring invalid value 'share' for parameter 'security'
smb.so(31299) SMBSlave::stat: QUrl("smb://host/dir/test.kmz")
smb.so(31299) SMBSlave::checkURL: checkURL  QUrl("smb://host/dir/test.kmz")
smb.so(31299) SMBSlave::checkURL: checkURL return3  QUrl("smb://host/dir/test.kmz")
smb.so(31299) SMBUrl::updateCache: updateCache  "/dir/test.kmz"
smb.so(31299) SMBSlave::cache_stat: size  515
kioexec(31295) KIOExec::KIOExec: Copying QUrl("smb://host/dir/test.kmz")  to QUrl("file:///home/jjm5/.cache/kioexec/krun/31295_0/test.kmz")

### The next line is a message that I've added, just before the
###     OrgKdeKIOExecdInterface kioexecd(QStringLiteral("org.kde.kioexecd"), ...
### line in KIOExec::KIOExec(const QStringList &args, bool tempFiles, const QString &suggestedFileName)
kioexec(31295) KIOExec::KIOExec: Telling kioexecd to watch the file

### The next line is just after the
###     mUseDaemon = !kioexecd.lastError().isValid();
### a few lines below
kioexec(31295) KIOExec::KIOExec: use daemon? true

### This is where the file copy actually starts
smb.so(31299) SMBSlave::smbCopyGet: src =  QUrl("smb://host/dir/test.kmz") , dest =  QUrl("file:///home/jjm5/.cache/kioexec/krun/31295_0/test.kmz")

smb.so(31299) SMBUrl::updateCache: updateCache  "/dir/test.kmz"
smb.so(31299) SMBSlave::cache_stat: size  515
smb.so(31299) SMBSlave::smbCopyGet: modified: ""
kioexec(31295) KIOExec::slotResult: All files downloaded, will call slotRunApp shortly
kioexec(31295) KIOExec::slotRunApp: EXEC  "/usr/bin/marble /home/jjm5/.cache/kioexec/krun/31295_0/test.kmz"
marble(31302) Marble::MarblePart::readSettings: Start: MarblePart::readSettings()

The significant parts are those marked with "###", showing that somehow the watch is being installed before the ioslave has actually started to copy the file.  The file does not exist at this time, so when the file is actually copied the daemon receives a "dirty" signal for it, which puts up the dialogue.

This dialogue is coming from kiod5, not the fallback in kioclient5.  I have verified this by using xprop and checking the WM_CLASS and _NET_WM_PID of the dialogue.  I have also verified wih strace that, when kiod5 is first told to watch the file, it does not yet exist:

23947 write(2, "kiod5(23947) KIOExecd::watch: Going to watch \"/home/jjm5/.cache/kioexec/krun/31295_0/test.kmz\" for changes, remote destination is \"smb://host/dir/test.kmz"..., 282) = 282
23947 stat("/home/jjm5/.cache/kioexec/krun/31295_0/test.kmz", 0x7ffdb7918980) = -1 ENOENT (No such file or directory)
23947 statfs("/home/jjm5/.cache/kioexec/krun/31295_0/test.kmz", 0x7ffdb7918730) = -1 ENOENT (No such file or directory)
23947 stat("/home/jjm5/.cache/kioexec/krun/31295_0", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
Comment 1 Elvis Angelaccio 2017-09-15 10:56:11 UTC
Hmm this is by design, recent versions of kioexec use a kded module + KDirWatcher to detect whether the file has been changed.

It seems this breaks with marble, but I'm not sure how we should fix it.
Comment 2 Jonathan Marten 2017-09-15 15:21:31 UTC
The receiving application, whether Marble or anything else, shouldn't be relevant.  The log shows that the fundamental problem is that kded module is being told to watch the file before the ioslave actually starts the copy.  Marble is not involved until the very last line above.
Comment 3 Jonathan Marten 2017-09-15 15:37:08 UTC
https://phabricator.kde.org/D7841
Comment 4 Jonathan Marten 2017-09-25 07:59:24 UTC
Git commit c76c1486ec79e8a16329207e9b293eed1244adfb by Jonathan Marten.
Committed on 25/09/2017 at 07:56.
Pushed by marten into branch 'master'.

kioexec: Watch the file when it has finished copying

To eliminate a spurious "The file has changed, do you want to upload
it?" dialogue.

Differential Revision: https://phabricator.kde.org/D7841

M  +27   -22   src/kioexec/main.cpp

https://commits.kde.org/kio/c76c1486ec79e8a16329207e9b293eed1244adfb