Unverified Commit 237c5129 authored by davelopez's avatar davelopez
Browse files

Safeguards `last_commit` access in Huggingface files

It seems the `last_commit` is not always returned by the API when
browsing files in the Huggingface repository. This ensures that even
if the 'last_commit' is None or absent, the files are correctly listed,
although without date or timestamp.
parent 0ee5dad0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ class HuggingFaceFilesSource(

    def _extract_timestamp(self, info: dict) -> Optional[str]:
        """Extract timestamp from Hugging Face file info to use it in the RemoteFile entry."""
        last_commit: dict = info.get("last_commit", {})
        last_commit: dict = info.get("last_commit") or {}
        return last_commit.get("date")

    def _get_file_hashes(self, info: dict) -> Optional[list[RemoteFileHash]]: