Skip to content

Commit 37f6156

Browse files
committed
Performance corrections to sync logic, transfer bar units, and unit tests
1 parent f9ce43d commit 37f6156

File tree

7 files changed

+129
-93
lines changed

7 files changed

+129
-93
lines changed

synapseclient/core/transfer_bar.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def increment_progress_bar(n: int, progress_bar: Union[tqdm, None]) -> None:
6868
def shared_download_progress_bar(
6969
file_size: int,
7070
custom_message: str = None,
71+
unit: str = "B",
7172
*,
7273
synapse_client: Optional["Synapse"] = None,
7374
):
@@ -91,7 +92,10 @@ def shared_download_progress_bar(
9192
syn = Synapse.get_client(synapse_client=synapse_client)
9293
with logging_redirect_tqdm(loggers=[syn.logger]):
9394
progress_bar = get_or_create_download_progress_bar(
94-
file_size=file_size, custom_message=custom_message, synapse_client=syn
95+
file_size=file_size,
96+
custom_message=custom_message,
97+
synapse_client=syn,
98+
unit=unit,
9599
)
96100
try:
97101
yield progress_bar
@@ -126,6 +130,7 @@ def get_or_create_download_progress_bar(
126130
file_size: int,
127131
postfix: str = None,
128132
custom_message: str = None,
133+
unit: str = "B",
129134
*,
130135
synapse_client: Optional["Synapse"] = None,
131136
) -> Union[tqdm, None]:
@@ -155,7 +160,7 @@ def get_or_create_download_progress_bar(
155160
progress_bar = tqdm(
156161
total=file_size,
157162
desc=custom_message or "Downloading files",
158-
unit="B",
163+
unit=unit or "it",
159164
unit_scale=True,
160165
smoothing=0,
161166
postfix=postfix,

synapseclient/models/folder.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ class Folder(FolderSynchronousProtocol, AccessControllable, StorableContainer):
156156
"""The last persistent instance of this object. This is used to determine if the
157157
object has been changed and needs to be updated in Synapse."""
158158

159+
_synced_from_synapse: Optional[bool] = field(
160+
default=False, repr=False, compare=False
161+
)
162+
"""Whether this object has been synced from Synapse. This is used to determine if
163+
`.sync_from_synapse_async` has already been called on this instance."""
164+
159165
@property
160166
def has_changed(self) -> bool:
161167
"""Determines if the object has been changed and needs to be updated in Synapse."""

0 commit comments

Comments
 (0)