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

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