Skip to content

Commit

Permalink
Introduce constants for JSON keys as requested by @drew2a
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Sep 8, 2022
1 parent d10f724 commit d588785
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
from tribler.core.utilities.utilities import froze_it


TOTAL = 'total'
LOADED = 'loaded'
ALL_LOADED = 'all_loaded'


def _safe_extended_peer_info(ext_peer_info):
"""
Given a string describing peer info, return a json.dumps() safe representation.
Expand Down Expand Up @@ -221,9 +226,9 @@ def get_files_info_json(download):
'time_added': Integer
}),
'checkpoints': schema(Checkpoints={
'total': Integer,
'loaded': Integer,
'all_loaded': Boolean,
TOTAL: Integer,
LOADED: Integer,
ALL_LOADED: Boolean,
})
}),
}
Expand All @@ -243,9 +248,9 @@ async def get_downloads(self, request):
get_files = params.get('get_files', '0') == '1'

checkpoints = {
"total": self.download_manager.checkpoints_count,
"loaded": self.download_manager.checkpoints_loaded,
"all_loaded": self.download_manager.all_checkpoints_are_loaded,
TOTAL: self.download_manager.checkpoints_count,
LOADED: self.download_manager.checkpoints_loaded,
ALL_LOADED: self.download_manager.all_checkpoints_are_loaded,
}

if not self.download_manager.all_checkpoints_are_loaded:
Expand Down

0 comments on commit d588785

Please sign in to comment.