# Buggy code
def on_export_download_dialog_done(action):
    if action == 0:
        dest_path = os.path.join(export_dir, dialog.dialog_widget.dialog_input.text())
        request_mgr = TriblerRequestManager()
        request_mgr.download_file(
            "channels/discovered/%s/mdblob" % mdblob_name,
            lambda data: on_export_download_request_done(dest_path, data),
        )

    dialog.close_dialog()


# Traceback (PackError)
ERROR   1562070054.96              rest_manager:83   (RESTRequest)  [Failure instance: Traceback: <class 'ipv8.messaging.serialization.PackError'>: Could not pack item 9: varlenI
error: unpack_from requires a buffer of at least 1869967971 bytes
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/http.py:2121:_finishRequestBody
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/http.py:2196:allContentReceived
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/http.py:920:requestReceived
/home/tribler/tudelft/tribler/Tribler/Core/Modules/restapi/rest_manager.py:118:process
--- <exception caught here> ---
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/server.py:199:process
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/server.py:259:render
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/resource.py:250:render
/home/tribler/tudelft/tribler/Tribler/Core/Modules/restapi/downloads_endpoint.py:347:render_PUT
/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py:166:from_file
/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py:135:from_signed_blob
/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py:140:from_signed_blob_with_offset
/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py:328:unpack_multiple
/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py:320:unpack_multiple
/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py:297:unpack
/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py:160:unpack_from
]
Traceback (most recent call last):
File "/home/tribler/.local/lib/python2.7/site-packages/twisted/web/server.py", line 199, in process
self.render(resrc)
File "/home/tribler/.local/lib/python2.7/site-packages/twisted/web/server.py", line 259, in render
body = resrc.render(self)
File "/home/tribler/.local/lib/python2.7/site-packages/twisted/web/resource.py", line 250, in render
return m(request)
File "/home/tribler/tudelft/tribler/Tribler/Core/Modules/restapi/downloads_endpoint.py", line 347, in render_PUT
payload = ChannelMetadataPayload.from_file(filename)
File "/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py", line 166, in from_file
return cls.from_signed_blob(f.read())
File "/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py", line 135, in from_signed_blob
return cls.from_signed_blob_with_offset(data, check_signature)[0]
File "/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py", line 140, in from_signed_blob_with_offset
unpack_list, end_offset = default_serializer.unpack_multiple(cls.format_list, data, offset=offset)
File "/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 328, in unpack_multiple
sys.exc_info()[2])
File "/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 320, in unpack_multiple
unpacked, unpacked_size = self.unpack(format, data, current_offset)
File "/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 297, in unpack
return self._packers[format].unpack_from(data, offset)
File "/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 160, in unpack_from
out, = unpack_from('>%ds' % length, data, offset + self.format_size)
PackError: Could not pack item 9: varlenI
error: unpack_from requires a buffer of at least 1869967971 bytes

# Fixed code
def on_export_download_dialog_done(action):
    if action == 0:
        dest_path = os.path.join(export_dir, dialog.dialog_widget.dialog_input.text())
        request_mgr = TriblerRequestManager()
        request_mgr.download_file(
            "mychannel/export",
            lambda data: on_export_download_request_done(dest_path, data),
        )

    dialog.close_dialog()