summaryrefslogtreecommitdiff
path: root/subplot/server.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-06-04 06:35:14 +0000
committerLars Wirzenius <liw@liw.fi>2021-06-04 06:35:14 +0000
commitf2a274ee1291531c1154176bca5b9a47e9c234bd (patch)
tree6721b515739c6e5f9236ffd6f4ecc2dfecc471d2 /subplot/server.py
parentcb33088dbedf4b772013f83b8226047cc4355dd2 (diff)
parent9c2590d2428f0d3de882686ec2ec5832e7123c62 (diff)
downloadobnam2-f2a274ee1291531c1154176bca5b9a47e9c234bd.tar.gz
Merge branch 'aead' into 'main'
add encryption of individual chunks Closes #110 See merge request larswirzenius/obnam!146
Diffstat (limited to 'subplot/server.py')
-rw-r--r--subplot/server.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/subplot/server.py b/subplot/server.py
index df594f7..cfe91ab 100644
--- a/subplot/server.py
+++ b/subplot/server.py
@@ -134,13 +134,21 @@ def json_body_matches(ctx, wanted=None):
assert_eq(body.get(key, "not.there"), wanted[key])
-def server_has_n_file_chunks(ctx, n=None):
+def server_has_n_chunks(ctx, n=None):
assert_eq = globals()["assert_eq"]
n = int(n)
- url = f"{ctx['server_url']}/chunks?data=true"
- _request(ctx, requests.get, url)
- num_chunks = len(ctx["http.json"])
- assert_eq(n, num_chunks)
+ files = find_files(ctx["config"]["chunks"])
+ files = [json.load(open(x)) for x in files if x.endswith(".meta")]
+ logging.debug(f"server_has_n_file_chunks: n={n}")
+ logging.debug(f"server_has_n_file_chunks: len(files)={len(files)}")
+ logging.debug(f"server_has_n_file_chunks: files={files}")
+ assert_eq(n, len(files))
+
+
+def find_files(root):
+ for dirname, _, names in os.walk(root):
+ for name in names:
+ yield os.path.join(dirname, name)
# Make an HTTP request.