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

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