[why] We cant find access_key_file in upload dest dir, because access_key_file was created in job result root dir,
[how] 1. Add job id to the access_key. 2. Use job id to find the job result root dir in upload uri.
Signed-off-by: Cao Xueliang caoxl78320@163.com --- container/result-webdav/nginx.conf | 8 +++++--- src/lib/job.cr | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/container/result-webdav/nginx.conf b/container/result-webdav/nginx.conf index 9297ae8..5ef3647 100644 --- a/container/result-webdav/nginx.conf +++ b/container/result-webdav/nginx.conf @@ -25,10 +25,12 @@ http {
access_by_lua_block { accesskey = ngx.var.cookie_ACCESSKEY - uri=ngx.var.request_uri - path=string.match(uri,"%g*/") + job_id = string.sub(accesskey, string.find(accesskey,"-") - string.len(accesskey)) + uri = ngx.var.request_uri + path = string.match(uri,"%g*/") + root_path = string.sub(path, 1, string.find(path, job_id) - 1)..job_id.."/"
- accesskey_file="/srv/"..path.."."..accesskey + accesskey_file = "/srv/"..root_path.."."..accesskey
local f = io.open(accesskey_file) if not f then diff --git a/src/lib/job.cr b/src/lib/job.cr index 2cb8a2c..f6c1762 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -191,7 +191,7 @@ class Job end
private def set_access_key - self["access_key"] = "#{Random::Secure.hex(10)}" unless @hash["access_key"]? + self["access_key"] = "#{Random::Secure.hex(10)}-#{id}" unless @hash["access_key"]? self["access_key_file"] = File.join("/srv/", "#{result_root}", ".#{access_key}") end