[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim-runtime] resources/kalarm/kalarmdir: Bug 370627: ignore temporary files created in calendar 
From:       David Jarvie <djarvie () kde ! org>
Date:       2016-10-31 20:48:50
Message-ID: E1c1JVi-0001Zk-Mv () code ! kde ! org
[Download RAW message or body]

Git commit 77f30c7471ce4f79e106cc91e8789c8c621fd1b7 by David Jarvie.
Committed on 31/10/2016 at 20:44.
Pushed by djarvie into branch 'master'.

Bug 370627: ignore temporary files created in calendar directory

Temporary files created by QSaveFile (called from ICalFormat::save())
on some systems caused error messages to appear in .xsession-errors
since they trigger KDirWatch but no longer exist when fileChanged()
tries to load them.

Copy of commit 4cd6df12ffc7cc7455f986e87c0d79d00d3123fa (16.08 branch).

M  +3    -4    resources/kalarm/kalarmdir/kalarmdirresource.cpp
M  +2    -1    resources/kalarm/kalarmdir/kalarmdirresource.h

http://commits.kde.org/kdepim-runtime/77f30c7471ce4f79e106cc91e8789c8c621fd1b7

diff --git a/resources/kalarm/kalarmdir/kalarmdirresource.cpp \
b/resources/kalarm/kalarmdir/kalarmdirresource.cpp index 80d6b19..293e677 100644
--- a/resources/kalarm/kalarmdir/kalarmdirresource.cpp
+++ b/resources/kalarm/kalarmdir/kalarmdirresource.cpp
@@ -58,8 +58,6 @@ using namespace KCalCore;
 using namespace Akonadi_KAlarm_Dir_Resource;
 using KAlarmResourceCommon::errorMessage;
 
-static bool isFileValid(const QString &file);
-
 static const char warningFile[] = "WARNING_README.txt";
 
 #define DEBUG_DATA \
@@ -1164,11 +1162,12 @@ QString KAlarmDirResource::removeEventFile(const QString \
                &eventId, const QString
 * Check whether a file is to be ignored.
 * Reply = false if file is to be ignored.
 */
-bool isFileValid(const QString &file)
+bool KAlarmDirResource::isFileValid(const QString &file) const
 {
     return !file.isEmpty()
        &&  !file.startsWith(QLatin1Char('.'))  &&  !file.endsWith(QLatin1Char('~'))
-       &&  file != QLatin1String(warningFile);
+       &&  file != QLatin1String(warningFile)
+       &&  QFile(filePath(file)).exists();   // a temporary file may no longer exist
 }
 
 AKONADI_RESOURCE_MAIN(KAlarmDirResource)
diff --git a/resources/kalarm/kalarmdir/kalarmdirresource.h \
b/resources/kalarm/kalarmdir/kalarmdirresource.h index 3458195..b274085 100644
--- a/resources/kalarm/kalarmdir/kalarmdirresource.h
+++ b/resources/kalarm/kalarmdir/kalarmdirresource.h
@@ -1,7 +1,7 @@
 /*
  *  kalarmdirresource.h  -  Akonadi directory resource for KAlarm
  *  Program:  kalarm
- *  Copyright  © 2011-2012 by David Jarvie <djarvie@kde.org>
+ *  Copyright  © 2011-2016 by David Jarvie <djarvie@kde.org>
  *
  *  This library is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU Library General Public License as published by
@@ -90,6 +90,7 @@ private:
     bool    createItem(const KAEvent &);
     bool    modifyItem(const KAEvent &);
     void    deleteItem(const KAEvent &);
+    bool    isFileValid(const QString &file) const;
 
     struct EventFile {  // data to be indexed by event ID
         EventFile() {}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic