[gnome-ostree] ostbuild: Only keep up to 5 snapshots by default
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree] ostbuild: Only keep up to 5 snapshots by default
- Date: Sun, 18 Nov 2012 19:04:41 +0000 (UTC)
commit 0193532a1a37fd8fe8e5156c43d415b6b999505a
Author: Colin Walters <walters verbum org>
Date: Sun Nov 18 14:03:06 2012 -0500
ostbuild: Only keep up to 5 snapshots by default
There's not a huge reason to keep older versions around, given that
each build has a resolved snapshot.
src/ostbuild/pyostbuild/jsondb.py | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/ostbuild/pyostbuild/jsondb.py b/src/ostbuild/pyostbuild/jsondb.py
index 3ff2930..e6ca233 100644
--- a/src/ostbuild/pyostbuild/jsondb.py
+++ b/src/ostbuild/pyostbuild/jsondb.py
@@ -26,9 +26,10 @@ import hashlib
import json
class JsonDB(object):
- def __init__(self, dirpath, prefix):
+ def __init__(self, dirpath, prefix, max_versions=5):
self._dirpath = dirpath
self._prefix = prefix
+ self._max_versions = max_versions
self._version_csum_re = re.compile(r'-(\d+)\.(\d+)-([0-9a-f]+).json$')
def _cmp_match_by_version(self, a, b):
@@ -128,6 +129,11 @@ class JsonDB(object):
latest_version[1] + 1, digest)
target_path = os.path.join(self._dirpath, target_name)
os.rename(tmppath, target_path)
+
+ if (len(files) + 1) > self._max_versions:
+ for f in files[(self._max_versions-1):]:
+ os.unlink(os.path.join(self._dirpath, f[3]))
+
return (target_path, True)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]