mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-02 03:06:41 +00:00
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
This commit is contained in:
parent
8b20399796
commit
7c937eabe7
@ -137,6 +137,21 @@ class BackupDB_v2:
|
|||||||
self.connection = connection
|
self.connection = connection
|
||||||
self.cursor = connection.cursor()
|
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):
|
def check_file(self, path, use_timestamps=True):
|
||||||
"""I will tell you if a given local file needs to be uploaded or not,
|
"""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
|
by looking in a database and seeing if I have a record of this file
|
||||||
|
Loading…
Reference in New Issue
Block a user