summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Jarvie <djarvie@kde.org>2016-10-31 20:44:14 (GMT)
committerDavid Jarvie <djarvie@kde.org>2016-10-31 20:44:44 (GMT)
commit77f30c7471ce4f79e106cc91e8789c8c621fd1b7 (patch)
tree53c08f9377560672f32bed29494615624d9be850
parentb2e40dd1edc4ab942fd64bc2fd60750959dd65c8 (diff)
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).
-rw-r--r--resources/kalarm/kalarmdir/kalarmdirresource.cpp7
-rw-r--r--resources/kalarm/kalarmdir/kalarmdirresource.h3
2 files changed, 5 insertions, 5 deletions
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() {}