Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/bockbuild.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Christoforides <alexis@thenull.net>2018-06-07 23:40:18 +0300
committerAlexis Christoforides <alexis@thenull.net>2018-06-08 00:19:47 +0300
commit890b2bbe45294bf313c6b6899a2c94a86231668a (patch)
treef0979832e5334a946cf5a8b4583200f09476f276
parent2979fbc782619edfc4b221c6f20907dc822dc8a3 (diff)
Allow artifacts to expire
-rwxr-xr-xbockbuild.py3
-rw-r--r--bockbuild/util/util.py5
2 files changed, 8 insertions, 0 deletions
diff --git a/bockbuild.py b/bockbuild.py
index af913c8..a3b0cfe 100755
--- a/bockbuild.py
+++ b/bockbuild.py
@@ -207,6 +207,9 @@ class Bockbuild:
elif not os.path.exists(package.build_artifact):
package.request_build('No artifact')
+ elif is_expired(package.build_artifact, config.artifact_lifespan_days):
+ package.request_build('Artifact expired (older than %d days)' % config.artifact_lifespan_days)
+
elif is_changed(package.buildstring, package.buildstring_file):
package.request_build('Updated')
diff --git a/bockbuild/util/util.py b/bockbuild/util/util.py
index 15a8cef..96233cc 100644
--- a/bockbuild/util/util.py
+++ b/bockbuild/util/util.py
@@ -11,6 +11,7 @@ import shutil
import tarfile
import hashlib
import stat
+from datetime import datetime,timedelta
import functools
# from
@@ -44,6 +45,7 @@ class config:
absolute_root = None # there is no file resolution beneath this path. Displayed paths are shortened by omitting this segment.
state_root = None
exit_code = exit_codes.NOTSET
+ artifact_lifespan_days = 7
class CommandException (Exception): # shell command failure
@@ -298,6 +300,9 @@ def is_changed(new, file, show_diff=True):
else:
return False
+def is_expired (path, age_cutoff_days):
+ artifact_age_days = (datetime.utcnow() - datetime.utcfromtimestamp(os.path.getmtime(path))).days
+ return artifact_age_days > age_cutoff_days
def get_filetype(path):
# the env variables are to work around a issue with OS X and 'file':