You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kf5-kservice/kbuildsycoca-Ignore-last-mo...

47 lines
1.8 KiB

From 21ce3b1e938c4b96154a7b00a15beef428ffce4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= <tim@siosm.fr>
Date: Sun, 15 May 2022 15:32:50 +0200
Subject: [PATCH] kbuildsycoca: Ignore last modified time when set to UNIX
Epoch
On some systems (i.e. Fedora Kinoite), all files in /usr have a last
modified timestamp of 0 (UNIX Epoch). In this case, always assume the
file as been changed.
We only get the current time once to speed up execution as we don't need
to be accurate in this case.
BUG: 442011
See:
- https://bugzilla.redhat.com/show_bug.cgi?id=2021087
- https://discussion.fedoraproject.org/t/kinoite-installation-with-utc-timezone-breaks-kde/34293/8
---
src/sycoca/kbuildsycoca.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/sycoca/kbuildsycoca.cpp b/src/sycoca/kbuildsycoca.cpp
index 0caeccf..3b0e011 100644
--- a/src/sycoca/kbuildsycoca.cpp
+++ b/src/sycoca/kbuildsycoca.cpp
@@ -607,7 +607,15 @@ static quint32 updateHash(const QString &file, quint32 hash)
if (fi.isReadable() && fi.isFile()) {
// This was using buff.st_ctime (in Waldo's initial commit to kstandarddirs.cpp in 2001), but that looks wrong?
// Surely we want to catch manual editing, while a chmod doesn't matter much?
- hash += fi.lastModified().toSecsSinceEpoch();
+ qint64 timestamp = fi.lastModified().toSecsSinceEpoch();
+ // On some systems (i.e. Fedora Kinoite), all files in /usr have a last
+ // modified timestamp of 0 (UNIX Epoch). In this case, always assume
+ // the file as been changed.
+ if (timestamp == 0) {
+ static qint64 now = QDateTime::currentDateTimeUtc().toSecsSinceEpoch();
+ timestamp = now;
+ }
+ hash += timestamp;
}
return hash;
}
--
2.36.1