def upload(self, uploadable):
uploader = self.getServiceNamed("uploader")
- return uploader.upload(uploadable)
+ return uploader.upload(uploadable, history=self.get_history())
def list_all_upload_statuses(self):
- uploader = self.getServiceNamed("uploader")
- return uploader.list_all_upload_statuses()
+ return self.get_history().list_all_upload_statuses()
def list_all_download_statuses(self):
return self.get_history().list_all_download_statuses()
name = "history"
MAX_DOWNLOAD_STATUSES = 10
+ MAX_UPLOAD_STATUSES = 10
def __init__(self):
self.all_downloads_statuses = weakref.WeakKeyDictionary()
self.recent_download_statuses = []
+ self.all_upload_statuses = weakref.WeakKeyDictionary()
+ self.recent_upload_statuses = []
def add_download(self, download_status):
self.all_downloads_statuses[download_status] = None
def list_all_download_statuses(self):
for ds in self.all_downloads_statuses:
yield ds
+
+ def add_upload(self, upload_status):
+ self.all_upload_statuses[upload_status] = None
+ self.recent_upload_statuses.append(upload_status)
+ while len(self.recent_upload_statuses) > self.MAX_UPLOAD_STATUSES:
+ self.recent_upload_statuses.pop(0)
+
+ def list_all_upload_statuses(self):
+ for us in self.all_upload_statuses:
+ yield us
implements(IUploader)
name = "uploader"
URI_LIT_SIZE_THRESHOLD = 55
- MAX_UPLOAD_STATUSES = 10
def __init__(self, helper_furl=None, stats_provider=None):
self._helper_furl = helper_furl
self.stats_provider = stats_provider
self._helper = None
self._all_uploads = weakref.WeakKeyDictionary() # for debugging
- self._all_upload_statuses = weakref.WeakKeyDictionary()
- self._recent_upload_statuses = []
log.PrefixingLogMixin.__init__(self, facility="tahoe.immutable.upload")
service.MultiService.__init__(self)
return (self._helper_furl, bool(self._helper))
- def upload(self, uploadable):
+ def upload(self, uploadable, history=None):
"""
Returns a Deferred that will fire with the UploadResults instance.
"""
uploader = CHKUploader(self.parent)
d2.addCallback(lambda x: uploader.start(eu))
- self._add_upload(uploader)
+ self._all_uploads[uploader] = None
+ if history:
+ history.add_upload(uploader.get_upload_status())
def turn_verifycap_into_read_cap(uploadresults):
# Generate the uri from the verifycap plus the key.
d3 = uploadable.get_encryption_key()
return res
d.addBoth(_done)
return d
-
- def _add_upload(self, uploader):
- s = uploader.get_upload_status()
- self._all_uploads[uploader] = None
- self._all_upload_statuses[s] = None
- self._recent_upload_statuses.append(s)
- while len(self._recent_upload_statuses) > self.MAX_UPLOAD_STATUSES:
- self._recent_upload_statuses.pop(0)
-
- def list_all_upload_statuses(self):
- for us in self._all_upload_statuses:
- yield us