Summary: | akonadi_kalarm_dir_resource watch triggered by temp files | ||
---|---|---|---|
Product: | [Applications] kalarm | Reporter: | Andrey Bondarenko <abone27> |
Component: | Akonadi | Assignee: | David Jarvie <djarvie> |
Status: | CLOSED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 2.11.4 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | 4cd6df12ffc7cc7455f986e87c0d79d00d3123fa | Version Fixed In: | 16.08.3 |
Attachments: |
Patch for testing
Updated patch for testing Patch with QFile::exists call moved to isFileValid function Revised patch |
Description
Andrey Bondarenko
2016-10-13 08:23:06 UTC
I don't see the error message in ~/.xsession-errors on my system, and therefore I can't test whether a fix will work. Can you confirm which line in kalarmdirresource.cpp produces the error - is it the call to loadFile(path, file) in fileChanged() ? It also isn't obvious where any temporary files are created with a name pattern like the one you report. The only place I can see that creates a temporary file is in fileStorage->save() in writeToFile(), which creates a file with '~' suffix. If I supply a patch, would you be able to rebuild and test it? Here is a example of more detailed log from kalarm: Qt-W [2016-10-23 11:53:10.027 +05] (kalarm:3906:default) unknown:0:unknown - QLayout: Attempting to add QLayout "" to YearlyRule "", which already has a layout Qt-C [2016-10-23 11:53:14.502 +05] (akonadi_kalarm_dir_resource_3:3650:default) kcalcore/src/icalformat.cpp:89:KCalCore::ICalFormat::load - load error Qt-C [2016-10-23 11:53:14.502 +05] (akonadi_kalarm_dir_resource_3:3650:default) kcalcore/src/icalformat.cpp:89:KCalCore::ICalFormat::load - load error Qt-W [2016-10-23 11:53:14.502 +05] (akonadi_kalarm_dir_resource_3:3650:log_kalarmdirresource) kdepim-runtime/resources/kalarm/kalarmdir/kalarmdirresource.cpp:446:KAlarmDirResource::loadFile - Error loading "~/.local/share/kalarm/active/KAlarm-1136218218.463.Hv3650" Qt-W [2016-10-23 11:53:14.504 +05] (akonadi_kalarm_dir_resource_3:3650:log_kalarmdirresource) kdepim-runtime/resources/kalarm/kalarmdir/kalarmdirresource.cpp:462:KAlarmDirResource::loadFile - File "~/.local/share/kalarm/active/KAlarm-1136218218.463" : event id differs from file name Qt-C [2016-10-23 11:53:14.977 +05] (akonadi_kalarm_dir_resource_3:3650:default) kcalcore/src/icalformat.cpp:89:KCalCore::ICalFormat::load - load error Qt-C [2016-10-23 11:53:14.978 +05] (akonadi_kalarm_dir_resource_3:3650:default) kcalcore/src/icalformat.cpp:89:KCalCore::ICalFormat::load - load error Qt-W [2016-10-23 11:53:14.978 +05] (akonadi_kalarm_dir_resource_3:3650:log_kalarmdirresource) kdepim-runtime/resources/kalarm/kalarmdir/kalarmdirresource.cpp:446:KAlarmDirResource::loadFile - Error loading "~/.local/share/kalarm/active/KAlarm-1136218218.463.Hv3650" Qt-W [2016-10-23 11:53:14.978 +05] (akonadi_kalarm_dir_resource_3:3650:log_kalarmdirresource) kdepim-runtime/resources/kalarm/kalarmdir/kalarmdirresource.cpp:986:KAlarmDirResource::modifyItem - Invalid mime type for collection I don't understand what code creates temporary file. It is possible that temp file created implicitly by library code. Strace shows that temp file created by akonadi_kalarm_dir_resource_n process, but I cannot find code responsible for this. I'm able to rebuild and test patch for version 15.12.3 available in Ubuntu 16.04, but I don't know how to properly upgrade entire stack to more recent versions like 16.04 or 16.08. It is possible to provide patch for old version? Probably a source of temporary files is QSaveFile instances used in function ICalFormat::save from kcalcore file src/icalformat.cpp. According to Qt docs (http://doc.qt.io/qt-5/qsavefile.html) QSaveFile creates temporary file, writes to it, then rename temporary file on commit. Looks like Implicit temp files are created under kalarm_dir_resource by QSaveFile in kcalcore and KDirWatch fire fileChanged on them. Because temporary filenames do not start with dot and not end with ~ they pass isFileValid. Created attachment 101844 [details]
Patch for testing
I've committed a fix in Applications/16.08 branch (commit 36009232d38e517b34816a014958a58fabd886a0).
I also attach a patch (which should apply to 15.12 branch) which I'd appreciate if you could test and let me know if it successfully fixes the bug.
I've recompiled kdepim-runtime with the patch but still have error messages Qt-D [2016-10-28 13:03:31.366 +05] (akonadi_kalarm_dir_resource_3:17381:log_kalarmdirresource) .../kdepim-runtime/resources/kalarm/kalarmdir/kalarmdirresource.cpp:857:KAlarmDirResource::fileChanged - "~/.local/share/kalarm/active/KAlarm-1360478297.791.U17381" Qt-D [2016-10-28 13:03:31.366 +05] (akonadi_kalarm_dir_resource_3:17381:log_kalarmdirresource) .../kdepim-runtime/resources/kalarm/kalarmdir/kalarmdirresource.cpp:442:KAlarmDirResource::loadFile - "~/.local/share/kalarm/active/KAlarm-1360478297.791.U17381" Qt-D [2016-10-28 13:03:31.366 +05] (akonadi_kalarm_dir_resource_3:17381:log_kcalcore) .../kcalcore/src/icalformat.cpp:83:KCalCore::ICalFormat::load - load "~/.local/share/kalarm/active/KAlarm-1360478297.791.U17381" Qt-C [2016-10-28 13:03:31.366 +05] (akonadi_kalarm_dir_resource_3:17381:log_kcalcore) .../kcalcore/src/icalformat.cpp:89:KCalCore::ICalFormat::load - load error: cannot open "~/.local/share/kalarm/active/KAlarm-1360478297.791.U17381" error "No such file or directory" Qt-D [2016-10-28 13:03:31.366 +05] (akonadi_kalarm_dir_resource_3:17381:log_kcalcore) .../kcalcore/src/icalformat.cpp:83:KCalCore::ICalFormat::load - load "~/.local/share/kalarm/active/KAlarm-1360478297.791.U17381" Qt-C [2016-10-28 13:03:31.366 +05] (akonadi_kalarm_dir_resource_3:17381:log_kcalcore) .../kcalcore/src/icalformat.cpp:89:KCalCore::ICalFormat::load - load error: cannot open "~/.local/share/kalarm/active/KAlarm-1360478297.791.U17381" error "No such file or directory" Method fileStorage->load() from kcalcore called from KAEvent KAlarmDirResource::loadFile still reports error if file does not exists. I think you should check file presence before calling load. Created attachment 101857 [details]
Updated patch for testing
Can you please test the attached patch which now checks for the file's existence before calling ICalFormat::load(). Thank you.
Created attachment 101896 [details]
Patch with QFile::exists call moved to isFileValid function
I still see errors in my ~/.xsession-errors file after updated patch.
Looks like moving QFile(file).exists() to isFileValid function solves the problem (see attached patch).
Created attachment 101901 [details]
Revised patch
Thanks for that. Your patch assumes that the current working directory is the calendar directory, which I'm not sure is a safe assumption. Can you please try out a revised version of your patch, which hopefully can be committed to fix the issue.
I don't see load errors after applying revised patch. The issue is resolved. Thank you for your assistance in testing the fix. This is now fixed for KAlarm version 2.11.10-5, which will be in KDE Applications 16.08.3. Commit 4cd6df12ffc7cc7455f986e87c0d79d00d3123fa (16.08 branch). |