Resource work
This commit is contained in:
parent
bf0e22d461
commit
81804b5d19
@ -122,6 +122,7 @@ class Resource:
|
||||
resource_data = None
|
||||
if hasattr(data, "read"):
|
||||
data_size = os.stat(data.name).st_size
|
||||
self.grand_total_parts = math.ceil(data_size/Resource.SDU)
|
||||
|
||||
if data_size <= Resource.MAX_EFFICIENT_SIZE:
|
||||
self.total_segments = 1
|
||||
@ -142,6 +143,8 @@ class Resource:
|
||||
|
||||
elif isinstance(data, bytes):
|
||||
data_size = len(data)
|
||||
self.grand_total_parts = math.ceil(data_size/Resource.SDU)
|
||||
|
||||
resource_data = data
|
||||
self.total_segments = 1
|
||||
self.segment_index = 1
|
||||
@ -167,7 +170,6 @@ class Resource:
|
||||
self.__watchdog_job_id = 0
|
||||
self.__progress_callback = progress_callback
|
||||
self.rtt = None
|
||||
self.grand_total_parts = math.ceil(data_size/Resource.SDU)
|
||||
|
||||
self.receiver_min_consecutive_height = 0
|
||||
|
||||
@ -717,6 +719,8 @@ class Resource:
|
||||
|
||||
def progress(self):
|
||||
if self.initiator:
|
||||
# TODO: Remove
|
||||
# progress = self.sent_parts / len(self.parts)
|
||||
self.processed_parts = (self.segment_index-1)*math.ceil(Resource.MAX_EFFICIENT_SIZE/Resource.SDU)
|
||||
self.processed_parts += self.sent_parts
|
||||
self.progress_total_parts = float(self.grand_total_parts)
|
||||
|
Loading…
Reference in New Issue
Block a user