diff --git a/olah/server.py b/olah/server.py index f5db66c..a8d31f1 100644 --- a/olah/server.py +++ b/olah/server.py @@ -119,6 +119,8 @@ class AppSettings(BaseSettings): # See also: https://huggingface.co/docs/hub/api#repo-listing-api # ====================== async def meta_proxy_common(repo_type: str, org: str, repo: str, commit: str, request: Request) -> Response: + # TODO: the head method of meta apis + # FIXME: do not show the private repos to other user besides owner, even though the repo was cached if repo_type not in REPO_TYPES_MAPPING.keys(): return error_page_not_found() if not await check_proxy_rules_hf(app, repo_type, org, repo): diff --git a/olah/utils/olah_cache.py b/olah/utils/olah_cache.py index a6e6701..a409c54 100644 --- a/olah/utils/olah_cache.py +++ b/olah/utils/olah_cache.py @@ -289,11 +289,16 @@ def _resize_file_size(self, file_size: int): f.seek(0, os.SEEK_END) bin_size = f.tell() + # FIXME: limit the resize method, because it may influence the _block_mask new_bin_size = self._get_header_size() + file_size with open(self.path, "rb+") as f: - # Extend file size - f.seek(0, os.SEEK_END) - f.write(b"\x00" * (new_bin_size - bin_size)) + f.seek(new_bin_size - 1) + f.write(b'\0') + f.truncate() + + # Extend file size (slow) + # f.seek(0, os.SEEK_END) + # f.write(b"\x00" * (new_bin_size - bin_size)) def resize(self, file_size: int): if not self.is_open: