diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-01-04 13:30:21 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-01-04 15:02:33 +0200 |
commit | c11b8bb76c50cff6aa481f17907ae7200ac55c01 (patch) | |
tree | f275d30b15891a71f11d8012f0573268310567bf /subplot | |
parent | f73b2a919dc2fe2d92eef6df9b7cab25af083fb3 (diff) | |
download | obnam2-c11b8bb76c50cff6aa481f17907ae7200ac55c01.tar.gz |
feat! record whether file was backed up and why, in a generation
This changes SQL schema.
Diffstat (limited to 'subplot')
-rw-r--r-- | subplot/client.py | 27 | ||||
-rw-r--r-- | subplot/client.yaml | 9 |
2 files changed, 36 insertions, 0 deletions
diff --git a/subplot/client.py b/subplot/client.py index 0a09d31..c1f5159 100644 --- a/subplot/client.py +++ b/subplot/client.py @@ -68,3 +68,30 @@ def generation_list_contains(ctx, gen_id=None): runcmd_stdout_contains = globals()["runcmd_stdout_contains"] gen_id = ctx["vars"][gen_id] runcmd_stdout_contains(ctx, text=gen_id) + + +def file_was_new(ctx, filename=None): + assert_eq = globals()["assert_eq"] + reason = get_backup_reason(ctx, filename) + assert_eq(reason, "(new)") + + +def file_was_changed(ctx, filename=None): + assert_eq = globals()["assert_eq"] + reason = get_backup_reason(ctx, filename) + assert_eq(reason, "(changed)") + + +def file_was_unchanged(ctx, filename=None): + assert_eq = globals()["assert_eq"] + reason = get_backup_reason(ctx, filename) + assert_eq(reason, "(unchanged)") + + +def get_backup_reason(ctx, filename): + runcmd_get_stdout = globals()["runcmd_get_stdout"] + stdout = runcmd_get_stdout(ctx) + lines = stdout.splitlines() + lines = [line for line in lines if filename in line] + line = lines[0] + return line.split()[-1] diff --git a/subplot/client.yaml b/subplot/client.yaml index e526304..db55679 100644 --- a/subplot/client.yaml +++ b/subplot/client.yaml @@ -15,3 +15,12 @@ - then: "generation list contains <{gen_id}>" function: generation_list_contains + +- then: "file {filename} was backed up because it was new" + function: file_was_new + +- then: "file {filename} was backed up because it was changed" + function: file_was_changed + +- then: "file {filename} was not backed up because it was unchanged" + function: file_was_unchanged |