From b88cdf6d76bd83a598d3abc473ca3ca6f178eaff Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Fri, 22 Apr 2022 14:14:50 +0200 Subject: [PATCH 1/2] track anon uploads --- docker/nginx/libs/skynet/tracker.lua | 2 +- docker/nginx/libs/skynet/tracker.spec.lua | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docker/nginx/libs/skynet/tracker.lua b/docker/nginx/libs/skynet/tracker.lua index 78fa6995..89848d2c 100644 --- a/docker/nginx/libs/skynet/tracker.lua +++ b/docker/nginx/libs/skynet/tracker.lua @@ -51,7 +51,7 @@ function _M.track_upload(skylink, status_code, auth_headers) local has_auth_headers = not utils.is_table_empty(auth_headers) local status_success = status_code >= 200 and status_code <= 299 - if skylink and status_success and has_auth_headers then + if skylink and status_success then local ok, err = ngx.timer.at(0, _M.track_upload_timer, skylink, auth_headers) if not ok then ngx.log(ngx.ERR, "Failed to create timer: ", err) end end diff --git a/docker/nginx/libs/skynet/tracker.spec.lua b/docker/nginx/libs/skynet/tracker.spec.lua index 41dab843..d6c59c4a 100644 --- a/docker/nginx/libs/skynet/tracker.spec.lua +++ b/docker/nginx/libs/skynet/tracker.spec.lua @@ -231,12 +231,17 @@ describe("track_upload", function() assert.stub(ngx.timer.at).was_not_called() end) - it("should not schedule a timer if auth headers are empty", function() + it("should schedule a timer if auth headers are empty", function() ngx.timer.at.invokes(function() return true, nil end) skynet_tracker.track_upload(valid_skylink, valid_status_code, {}) - assert.stub(ngx.timer.at).was_not_called() + assert.stub(ngx.timer.at).was_called_with( + 0, + skynet_tracker.track_upload_timer, + valid_skylink, + {} + ) end) it("should log an error if timer failed to create", function() From d27dca72d13bfada3d75501d98f7585693872ff1 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Fri, 22 Apr 2022 14:26:34 +0200 Subject: [PATCH 2/2] remove unused variable --- docker/nginx/libs/skynet/tracker.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/nginx/libs/skynet/tracker.lua b/docker/nginx/libs/skynet/tracker.lua index 89848d2c..56f9dcc4 100644 --- a/docker/nginx/libs/skynet/tracker.lua +++ b/docker/nginx/libs/skynet/tracker.lua @@ -48,7 +48,6 @@ function _M.track_upload_timer(premature, skylink, auth_headers) end function _M.track_upload(skylink, status_code, auth_headers) - local has_auth_headers = not utils.is_table_empty(auth_headers) local status_success = status_code >= 200 and status_code <= 299 if skylink and status_success then