From 7cff991e79cf6a58b8a606e974ec81f0759c183e Mon Sep 17 00:00:00 2001
From: David Stainton <dstainton415@gmail.com>
Date: Sat, 12 Sep 2015 20:09:10 +0200
Subject: [PATCH] Add is_new_file_time db helper function

this is for comparing mtimes
---
 src/allmydata/backupdb.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/allmydata/backupdb.py b/src/allmydata/backupdb.py
index 3f43eee0..9e8b5273 100644
--- a/src/allmydata/backupdb.py
+++ b/src/allmydata/backupdb.py
@@ -415,3 +415,28 @@ class MagicFolderDB(BackupDB):
                                 " WHERE path=?",
                                 (size, mtime, ctime, fileid, version, path))
         self.connection.commit()
+
+    def is_new_file_time(self, path, relpath_u):
+        """recent_file_time returns true if the file is recent...
+        meaning it's current mtime matched the mtime that was previously stored in the db.
+        """
+        print "check_file_time %s %s" % (path, relpath_u)
+        path = abspath_expanduser_unicode(path)
+        s = os.stat(path)
+        size = s[stat.ST_SIZE]
+        ctime = s[stat.ST_CTIME]
+        mtime = s[stat.ST_MTIME]
+        now = time.time()
+        c = self.cursor
+        c.execute("SELECT size,mtime,ctime,fileid"
+                  " FROM local_files"
+                  " WHERE path=?",
+                  (relpath_u,))
+        row = self.cursor.fetchone()
+        if not row:
+            return True
+        (last_size,last_mtime,last_ctime,last_fileid) = row
+        if int(mtime) == int(last_mtime):
+            return False
+        else:
+            return True
-- 
2.45.2