Alternative DBs: touch meta_data.db to record last access time

This commit is contained in:
Doug Blank 2015-05-15 06:42:13 -04:00
parent b1d07b8e70
commit ae11d8b484
2 changed files with 19 additions and 1 deletions

View File

@ -67,6 +67,13 @@ from gramps.gen.lib.tag import Tag
_LOG = logging.getLogger(DBLOGNAME)
def touch(fname, mode=0o666, dir_fd=None, **kwargs):
## After http://stackoverflow.com/questions/1158076/implement-touch-using-python
flags = os.O_CREAT | os.O_APPEND
with os.fdopen(os.open(fname, flags=flags, mode=mode, dir_fd=dir_fd)) as f:
os.utime(f.fileno() if os.utime in os.supports_fd else fname,
dir_fd=None if os.supports_fd else dir_fd, **kwargs)
class Environment(object):
"""
Implements the Environment API.
@ -1483,6 +1490,8 @@ class DictionaryDb(DbWriteBase, DbReadBase, UpdateCallback, Callback):
writer = XmlWriter(self, User(), strip_photos=0, compress=1)
filename = os.path.join(self._directory, "data.gramps")
writer.write(filename)
filename = os.path.join(self._directory, "meta_data.db")
touch(filename)
def find_backlink_handles(self, handle, include_classes=None):
return []

View File

@ -64,6 +64,13 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
_LOG = logging.getLogger(DBLOGNAME)
def touch(fname, mode=0o666, dir_fd=None, **kwargs):
## After http://stackoverflow.com/questions/1158076/implement-touch-using-python
flags = os.O_CREAT | os.O_APPEND
with os.fdopen(os.open(fname, flags=flags, mode=mode, dir_fd=dir_fd)) as f:
os.utime(f.fileno() if os.utime in os.supports_fd else fname,
dir_fd=None if os.supports_fd else dir_fd, **kwargs)
class Environment(object):
"""
Implements the Environment API.
@ -1959,7 +1966,9 @@ class DbDjango(DbWriteBase, DbReadBase, UpdateCallback, Callback):
return None
def close(self):
pass
if self._directory:
filename = os.path.join(self._directory, "meta_data.db")
touch(filename)
def get_surname_list(self):
return []