-
Notifications
You must be signed in to change notification settings - Fork 61
fix/ota-2183/Enable streaming of garage-push/deploy uploads #1305
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
class RequestPool { | ||
public: | ||
RequestPool(const TreehubServer& server, int max_curl_requests, RunMode mode); | ||
RequestPool(TreehubServer& server, int max_curl_requests, RunMode mode); | ||
~RequestPool(); | ||
void AddQuery(const OSTreeObject::ptr& request); | ||
void AddUpload(const OSTreeObject::ptr& request); | ||
|
@@ -42,7 +42,7 @@ class RequestPool { | |
RateController rate_controller_; | ||
int running_requests_; | ||
int total_requests_made_{0}; | ||
const TreehubServer& server_; | ||
TreehubServer& server_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's too bad we lose this const-ness. It doesn't seem so critical, though, and I don't have a better solution available yet, though, so maybe it's fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I feel sorry for the loss too. I have tried. |
||
CURLM* multi_; | ||
std::list<OSTreeObject::ptr> query_queue_; | ||
std::list<OSTreeObject::ptr> upload_queue_; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,16 @@ def do_POST(self): | |
self.send_response_only(200) | ||
self.end_headers() | ||
return | ||
elif ctype == 'application/octet-stream': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case of 'application/octet-stream' we can read the posted file/body just from the socket buffer, so something like that should work
But, if the given implementation works then it's ok - this is just a test tool There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks Mike, I'll try your way. I was also just gonna try this: import cgitb; cgitb.enable() form = cgi.FieldStorage() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tested Mike's way, t_deploy output: diff: /tmp/aktualizr-951f-8561-2d1e-5c0a/d5ea-2beb-dir/objects/: No such file or directory There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, I've just checked and it works for me, I missed an ending There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I added the return statement. maybe we can see how it work out In CI test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I think, I understand where is a problem. It's not enough just set a header that indicates a type of transferring data, actual data should be transferred according to the declared way. In this particular case we set 'application/octet-stream' header but actually transfer data as |
||
length = int(self.headers['content-length']) | ||
body = self.rfile.read(length) | ||
full_path = os.path.join(repo_path, self.path[1:]) | ||
os.system("mkdir -p %s" % os.path.dirname(full_path)) | ||
with open(full_path, "wb") as f: | ||
f.write(body) | ||
self.send_response_only(204) | ||
self.end_headers() | ||
return | ||
|
||
self.send_response_only(400) | ||
self.end_headers() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, if a file opening or getting its stat fails the code control flow will end up at line #333 ?
I am just wondering if throwing an exception (like at line #229) will work in this case, at first glance it won't work (just thinking loudly :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwing an exception might be better.