Blame SOURCES/dconf-0.28.0-db-mtime.patch

e9528a
From 6a6797446f13378035a2700253546b524d629c8a Mon Sep 17 00:00:00 2001
e9528a
From: Marek Kasik <mkasik@redhat.com>
e9528a
Date: Tue, 10 Jul 2018 18:29:16 +0200
e9528a
Subject: [PATCH] Check mtimes of files when updating databases
e9528a
e9528a
Do not check just mtimes of directories in /etc/dconf/db/
e9528a
but also mtimes of the files in those directories
e9528a
to catch all modifications in them.
e9528a
e9528a
https://bugzilla.gnome.org/show_bug.cgi?id=708258
e9528a
---
e9528a
 bin/dconf-update.vala | 41 ++++++++++++++++++++++++++++++++++-------
e9528a
 1 file changed, 34 insertions(+), 7 deletions(-)
e9528a
e9528a
diff --git a/bin/dconf-update.vala b/bin/dconf-update.vala
e9528a
index d452092..5aac6c7 100644
e9528a
--- a/bin/dconf-update.vala
e9528a
+++ b/bin/dconf-update.vala
e9528a
@@ -162,21 +162,48 @@ Gvdb.HashTable read_directory (string dirname) throws GLib.Error {
e9528a
 	return table;
e9528a
 }
e9528a
 
e9528a
+time_t get_directory_mtime (string dirname, Posix.Stat dir_buf) throws GLib.Error {
e9528a
+	Posix.Stat lockdir_buf;
e9528a
+	Posix.Stat file_buf;
e9528a
+	time_t dir_mtime = dir_buf.st_mtime;
e9528a
+
e9528a
+	var files = list_directory (dirname, Posix.S_IFREG);
e9528a
+	files.sort (strcmp);
e9528a
+	files.reverse ();
e9528a
+
e9528a
+	foreach (var filename in files) {
e9528a
+		if (Posix.stat (filename, out file_buf) == 0 && file_buf.st_mtime > dir_mtime)
e9528a
+			dir_mtime = file_buf.st_mtime;
e9528a
+	}
e9528a
+
e9528a
+	if (Posix.stat (dirname + "/locks", out lockdir_buf) == 0 && Posix.S_ISDIR (lockdir_buf.st_mode)) {
e9528a
+		if (lockdir_buf.st_mtime > dir_mtime) {
e9528a
+			// if the lock directory has been updated more recently then consider its timestamp instead
e9528a
+			dir_mtime = lockdir_buf.st_mtime;
e9528a
+		}
e9528a
+
e9528a
+		files = list_directory (dirname + "/locks", Posix.S_IFREG);
e9528a
+		files.sort (strcmp);
e9528a
+		files.reverse ();
e9528a
+
e9528a
+		foreach (var filename in files) {
e9528a
+			if (Posix.stat (filename, out file_buf) == 0 && file_buf.st_mtime > dir_mtime)
e9528a
+				dir_mtime = file_buf.st_mtime;
e9528a
+		}
e9528a
+	}
e9528a
+
e9528a
+	return dir_mtime;
e9528a
+}
e9528a
+
e9528a
 void maybe_update_from_directory (string dirname) throws GLib.Error {
e9528a
 	Posix.Stat dir_buf;
e9528a
 
e9528a
 	if (Posix.stat (dirname, out dir_buf) == 0 && Posix.S_ISDIR (dir_buf.st_mode)) {
e9528a
-		Posix.Stat lockdir_buf;
e9528a
 		Posix.Stat file_buf;
e9528a
 
e9528a
 		var filename = dirname.substring (0, dirname.length - 2);
e9528a
 
e9528a
-		if (Posix.stat (dirname + "/locks", out lockdir_buf) == 0 && lockdir_buf.st_mtime > dir_buf.st_mtime) {
e9528a
-			// if the lock directory has been updated more recently then consider its timestamp instead
e9528a
-			dir_buf.st_mtime = lockdir_buf.st_mtime;
e9528a
-		}
e9528a
-
e9528a
-		if (Posix.stat (filename, out file_buf) == 0 && file_buf.st_mtime > dir_buf.st_mtime) {
e9528a
+		if (Posix.stat (filename, out file_buf) == 0 && file_buf.st_mtime > get_directory_mtime (dirname, dir_buf)) {
e9528a
 			return;
e9528a
 		}
e9528a
 
e9528a
-- 
e9528a
2.17.1
e9528a