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

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