Merge pull request from johscheuer/add-is-present-method-sidecar

Add sidecar method to check if a file is present
This commit is contained in:
Johannes Scheuermann 2022-05-03 07:22:23 +01:00 committed by GitHub
commit 9665786785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions
packaging/docker

View File

@ -518,10 +518,16 @@ class Server(BaseHTTPRequestHandler):
return
if self.path.startswith("/check_hash/"):
try:
self.send_text(check_hash(self.path[12:]), add_newline=False)
self.send_text(check_hash(os.path.basename(self.path)), add_newline=False)
except FileNotFoundError:
self.send_error(404, "Path not found")
self.end_headers()
if self.path.startswith("/is_present/"):
if is_present(os.path.basename(self.path))):
self.send_text("OK")
else:
self.send_error(404, "Path not found")
self.end_headers()
elif self.path == "/ready":
self.send_text(ready())
elif self.path == "/substitutions":
@ -599,6 +605,10 @@ def check_hash(filename):
return m.hexdigest()
def is_present(filename):
return os.path.exists(os.path.join(Config.shared().output_dir, filename))
def copy_files():
config = Config.shared()
if config.require_not_empty: