From: David Stainton Date: Thu, 11 Jun 2015 21:20:40 +0000 (-0700) Subject: Add check_file_db_exists to backupdb api X-Git-Url: https://git.rkrishnan.org/vdrive/%22news.html/frontends/FTP-and-SFTP.rst?a=commitdiff_plain;h=f3b5bb2232b83c1d6ec4659d36e11dd4c39e188b;p=tahoe-lafs%2Ftahoe-lafs.git 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 --- 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