summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2016-06-24 17:41:44 +0000
committerLars Wirzenius <liw@liw.fi>2016-06-25 16:05:41 +0000
commit79c4579c78caff17d31d46776d512dae3f879d3b (patch)
treeb3b8120154cb0d0893e27afb1b2b2553a30a2062
parent0dc3b5ce8ce8efb3bc1472af9fdebfed081aca5e (diff)
downloadobnam-79c4579c78caff17d31d46776d512dae3f879d3b.tar.gz
Add flush_client method and fix RepositoryClientNotLocked instance
This may be used to force any in-memory caches for an open client in a repository to be written out, and then dropped, to reduct memory use. Only green-albatross implements this, for now.
-rw-r--r--obnamlib/delegator.py7
-rw-r--r--obnamlib/fmt_ga/client.py3
-rw-r--r--obnamlib/plugins/backup_plugin.py4
-rw-r--r--obnamlib/repo_interface.py8
4 files changed, 21 insertions, 1 deletions
diff --git a/obnamlib/delegator.py b/obnamlib/delegator.py
index baad29fd..e5cf9b66 100644
--- a/obnamlib/delegator.py
+++ b/obnamlib/delegator.py
@@ -171,7 +171,12 @@ class RepositoryDelegator(obnamlib.RepositoryInterface):
def _require_got_client_lock(self, client_name):
if not self.got_client_lock(client_name):
- raise obnamlib.RepositoryClientNotLocked()
+ raise obnamlib.RepositoryClientNotLocked(client_name=client_name)
+
+ def flush_client(self, client_name):
+ self._require_got_client_lock(client_name)
+ client = self._lookup_client(client_name)
+ client.flush()
def commit_client(self, client_name):
self._require_got_client_lock(client_name)
diff --git a/obnamlib/fmt_ga/client.py b/obnamlib/fmt_ga/client.py
index d29c85a6..85417d04 100644
--- a/obnamlib/fmt_ga/client.py
+++ b/obnamlib/fmt_ga/client.py
@@ -74,6 +74,9 @@ class GAClient(object):
def get_dirname(self):
return self._dirname
+ def flush(self):
+ self._save_file_metadata()
+
def commit(self):
self._load_data()
self._finish_current_generation_if_any()
diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py
index e17d0c31..13334432 100644
--- a/obnamlib/plugins/backup_plugin.py
+++ b/obnamlib/plugins/backup_plugin.py
@@ -406,6 +406,10 @@ class BackupPlugin(obnamlib.ObnamPlugin):
if e.errno in (errno.ENOSPC, errno.EPIPE):
raise
+ if metadata.isdir() and not self.pretend:
+ self.repo.flush_client(self.client_name)
+ self.app.dump_memory_profile('after flushing client')
+
if self.checkpoint_manager.time_for_checkpoint():
self.make_checkpoint()
self.progress.what(pathname)
diff --git a/obnamlib/repo_interface.py b/obnamlib/repo_interface.py
index b3744de5..f948c68e 100644
--- a/obnamlib/repo_interface.py
+++ b/obnamlib/repo_interface.py
@@ -543,6 +543,14 @@ class RepositoryInterface(object):
'''
raise NotImplementedError()
+ def flush_client(self, client_name):
+ '''Flush cached data from client. This is not a commit.
+
+ This is a NOP, unless the a specific repository format gives
+ it meaning.
+
+ '''
+
def commit_client(self, client_name):
'''Commit changes to client and DO NOT unlock it.