diff --git a/swh/web/browse/snapshot_context.py b/swh/web/browse/snapshot_context.py --- a/swh/web/browse/snapshot_context.py +++ b/swh/web/browse/snapshot_context.py @@ -10,7 +10,6 @@ from django.core.cache import cache from django.shortcuts import render -from django.template.defaultfilters import filesizeformat from django.utils.html import escape from swh.model.hashutil import hash_to_bytes @@ -772,7 +771,6 @@ ) if f["length"] is not None: sum_file_sizes += f["length"] - f["length"] = filesizeformat(f["length"]) if f["name"].lower().startswith("readme"): readmes[f["name"]] = f["checksums"]["sha1"] @@ -796,7 +794,6 @@ if root_directory: nb_files = len(files) nb_dirs = len(dirs) - sum_file_sizes = filesizeformat(sum_file_sizes) dir_path = "/" + path revision_found = True @@ -1012,7 +1009,7 @@ content_url=browse_content_link, mimetype=content_data.get("mimetype"), encoding=content_data.get("encoding"), - size=filesizeformat(content_data.get("length", 0)), + size=content_data.get("length", 0), language=content_data.get("language"), root_directory=root_directory, path=f"/{filepath}", diff --git a/swh/web/browse/views/content.py b/swh/web/browse/views/content.py --- a/swh/web/browse/views/content.py +++ b/swh/web/browse/views/content.py @@ -10,7 +10,6 @@ from django.http import HttpResponse, JsonResponse from django.shortcuts import render -from django.template.defaultfilters import filesizeformat from swh.model.hashutil import hash_to_hex from swh.model.identifiers import CONTENT, DIRECTORY, RELEASE, REVISION, SNAPSHOT @@ -315,7 +314,7 @@ content_url=content_url, mimetype=content_data.get("mimetype"), encoding=content_data.get("encoding"), - size=filesizeformat(content_data.get("length", 0)), + size=content_data.get("length", 0), language=content_data.get("language"), root_directory=root_dir, path=f"/{path}" if path else None, diff --git a/swh/web/browse/views/directory.py b/swh/web/browse/views/directory.py --- a/swh/web/browse/views/directory.py +++ b/swh/web/browse/views/directory.py @@ -9,7 +9,6 @@ from django.http import HttpResponse from django.shortcuts import redirect, render -from django.template.defaultfilters import filesizeformat from swh.model.identifiers import DIRECTORY, RELEASE, REVISION, SNAPSHOT from swh.web.browse.browseurls import browse_route @@ -130,14 +129,11 @@ ) if f["length"] is not None: sum_file_sizes += f["length"] - f["length"] = filesizeformat(f["length"]) if f["name"].lower().startswith("readme"): readmes[f["name"]] = f["checksums"]["sha1"] readme_name, readme_url, readme_html = get_readme_to_display(readmes) - sum_file_sizes = filesizeformat(sum_file_sizes) - dir_metadata = DirectoryMetadata( object_type=DIRECTORY, object_id=sha1_git, diff --git a/swh/web/browse/views/revision.py b/swh/web/browse/views/revision.py --- a/swh/web/browse/views/revision.py +++ b/swh/web/browse/views/revision.py @@ -9,7 +9,6 @@ from django.http import JsonResponse from django.shortcuts import render -from django.template.defaultfilters import filesizeformat from django.utils.safestring import mark_safe from swh.model.hashutil import hash_to_bytes @@ -515,8 +514,6 @@ url_args={"sha1_git": sha1_git}, query_params=query_params, ) - if f["length"] is not None: - f["length"] = filesizeformat(f["length"]) if f["name"].lower().startswith("readme"): readmes[f["name"]] = f["checksums"]["sha1"] diff --git a/swh/web/common/typing.py b/swh/web/common/typing.py --- a/swh/web/common/typing.py +++ b/swh/web/common/typing.py @@ -167,7 +167,7 @@ content_url: str mimetype: str encoding: str - size: str + size: int language: str path: Optional[str] filename: Optional[str] @@ -182,7 +182,7 @@ directory: str nb_files: int nb_dirs: int - sum_file_sizes: str + sum_file_sizes: int root_directory: Optional[str] path: str revision: Optional[str] diff --git a/swh/web/templates/includes/directory-display.html b/swh/web/templates/includes/directory-display.html --- a/swh/web/templates/includes/directory-display.html +++ b/swh/web/templates/includes/directory-display.html @@ -48,7 +48,7 @@ {{ f.perms }} - {{ f.length }} + {% if f.length is not None %}{{ f.length|filesizeformat }}{% endif %} {% endfor %}