diff --git a/pulsar/client/transport/curl.py b/pulsar/client/transport/curl.py index 90c5aa98f31c430d84b7a3af98037109522f607b..0bbb9676c9017c94f0b54f1aa587ad967700097d 100644 --- a/pulsar/client/transport/curl.py +++ b/pulsar/client/transport/curl.py @@ -66,10 +66,18 @@ def post_file(url, path): def get_file(url, path): + if path and os.path.exists(path): + buf = _open_output(path, 'ab') + size = os.path.getsize(path) + else: + buf = _open_output(path) + size = 0 buf = _open_output(path) try: c = _new_curl_object_for_url(url) c.setopt(c.WRITEFUNCTION, buf.write) + if size > 0: + c.setopt(c.RESUME_FROM, size) c.perform() status_code = c.getinfo(HTTP_CODE) if int(status_code) != 200: @@ -79,8 +87,8 @@ def get_file(url, path): buf.close() -def _open_output(output_path): - return open(output_path, 'wb') if output_path else BytesIO() +def _open_output(output_path, mode='wb'): + return open(output_path, mode) if output_path else BytesIO() def _new_curl_object_for_url(url):