[PATCH v5 compass-ci] container/result-webdav: add symbolic link after uploading file

[why] Use curl to upload files, cannot add symbolic links. [how] nginx adds a symbolic link locally after receiving the file. Signed-off-by: cuiyili <2268260388@qq.com> --- container/result-webdav/nginx.conf | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/container/result-webdav/nginx.conf b/container/result-webdav/nginx.conf index 5ef3647..1085492 100644 --- a/container/result-webdav/nginx.conf +++ b/container/result-webdav/nginx.conf @@ -14,7 +14,7 @@ http { server_tokens off; client_max_body_size 100m; - location / { + location /result { allow all; root /srv/; @@ -39,6 +39,32 @@ http { io.close(f) } } + location /initrd { + allow all; + root /srv/; + autoindex on; + create_full_put_path on; + dav_methods PUT MKCOL; + dav_access user:rw group:rw all:rw; + + access_by_lua_block { + uri = ngx.var.request_uri + + path = string.match(uri,"%g*/") + uploadfile = string.match(uri, ".+/([^/]*%.%w+)$") + second_dir = string.match(uri, "/.+/(.*)/.+") + + if (second_dir == "pkg") + then + link_name = "latest.cgz" + else + link_name = string.match(uploadfile, "(.*)_%d+%.cgz")..".cgz" + end + + root_patch = "/srv/"..path + io.popen("cd "..root_patch.."&& ln -sf "..uploadfile.." "..link_name) + } + } } } -- 2.23.0

On Mon, Nov 23, 2020 at 06:47:43PM +0800, Cui Yili wrote:
[why] Use curl to upload files, cannot add symbolic links.
please show the original error message Thanks, Ping
[how] nginx adds a symbolic link locally after receiving the file.
Signed-off-by: cuiyili <2268260388@qq.com> --- container/result-webdav/nginx.conf | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/container/result-webdav/nginx.conf b/container/result-webdav/nginx.conf index 5ef3647..1085492 100644 --- a/container/result-webdav/nginx.conf +++ b/container/result-webdav/nginx.conf @@ -14,7 +14,7 @@ http { server_tokens off; client_max_body_size 100m;
- location / { + location /result { allow all; root /srv/;
@@ -39,6 +39,32 @@ http { io.close(f) } } + location /initrd { + allow all; + root /srv/; + autoindex on; + create_full_put_path on; + dav_methods PUT MKCOL; + dav_access user:rw group:rw all:rw; + + access_by_lua_block { + uri = ngx.var.request_uri + + path = string.match(uri,"%g*/") + uploadfile = string.match(uri, ".+/([^/]*%.%w+)$") + second_dir = string.match(uri, "/.+/(.*)/.+") + + if (second_dir == "pkg") + then + link_name = "latest.cgz" + else + link_name = string.match(uploadfile, "(.*)_%d+%.cgz")..".cgz" + end + + root_patch = "/srv/"..path + io.popen("cd "..root_patch.."&& ln -sf "..uploadfile.." "..link_name) + } + }
} } -- 2.23.0

On Mon, Nov 23, 2020 at 06:47:43PM +0800, Cui Yili wrote:
[why] Use curl to upload files, cannot add symbolic links.
[how] nginx adds a symbolic link locally after receiving the file.
Signed-off-by: cuiyili <2268260388@qq.com> --- container/result-webdav/nginx.conf | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/container/result-webdav/nginx.conf b/container/result-webdav/nginx.conf index 5ef3647..1085492 100644 --- a/container/result-webdav/nginx.conf +++ b/container/result-webdav/nginx.conf @@ -14,7 +14,7 @@ http { server_tokens off; client_max_body_size 100m;
- location / { + location /result { allow all; root /srv/;
@@ -39,6 +39,32 @@ http { io.close(f) } } + location /initrd { + allow all; + root /srv/; + autoindex on; + create_full_put_path on; + dav_methods PUT MKCOL; + dav_access user:rw group:rw all:rw; + + access_by_lua_block { + uri = ngx.var.request_uri + + path = string.match(uri,"%g*/") + uploadfile = string.match(uri, ".+/([^/]*%.%w+)$")
uploadfile => upload_file? Thanks, Xueliang
+ second_dir = string.match(uri, "/.+/(.*)/.+") + + if (second_dir == "pkg") + then + link_name = "latest.cgz" + else + link_name = string.match(uploadfile, "(.*)_%d+%.cgz")..".cgz" + end + + root_patch = "/srv/"..path + io.popen("cd "..root_patch.."&& ln -sf "..uploadfile.." "..link_name) + } + }
} } -- 2.23.0
participants (3)
-
Cao Xueliang
-
Cui Yili
-
Li Ping