From 7c937eabe7e35b94a2e35f6e6b3af02b825e5f5d Mon Sep 17 00:00:00 2001 From: David Stainton Date: Thu, 11 Jun 2015 14:20:40 -0700 Subject: [PATCH] Add check_file_db_exists to backupdb api - this backupdb utility function checks to if a file's entry exists in the db but does not stat the file on disk or otherwise talk to the filesystem --- src/allmydata/backupdb.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/allmydata/backupdb.py b/src/allmydata/backupdb.py index d0c22616..537d4305 100644 --- a/src/allmydata/backupdb.py +++ b/src/allmydata/backupdb.py @@ -137,6 +137,21 @@ class BackupDB_v2: self.connection = connection self.cursor = connection.cursor() + def check_file_db_exists(self, path): + """I will tell you if a given file has an entry in my database or not + by returning True or False. + """ + c = self.cursor + c.execute("SELECT size,mtime,ctime,fileid" + " FROM local_files" + " WHERE path=?", + (path,)) + row = self.cursor.fetchone() + if not row: + return False + else: + return True + def check_file(self, path, use_timestamps=True): """I will tell you if a given local file needs to be uploaded or not, by looking in a database and seeing if I have a record of this file -- 2.45.2