Skip to content
Snippets Groups Projects
Unverified Commit da5be60b authored by bhavan-kaya's avatar bhavan-kaya Committed by GitHub
Browse files

[Bug Fix]: Error: 'GCSFile' object has no attribute 'name' when processing PDF...

[Bug Fix]: Error: 'GCSFile' object has no attribute 'name' when processing PDF files #12108 (#12113)

* Update base.py

* Review changes

* Trim trailing whitespace
parent 4a8c2923
No related branches found
No related tags found
No related merge requests found
...@@ -77,14 +77,19 @@ def _format_file_timestamp(timestamp: float) -> Optional[str]: ...@@ -77,14 +77,19 @@ def _format_file_timestamp(timestamp: float) -> Optional[str]:
def default_file_metadata_func( def default_file_metadata_func(
file_path: str, fs: Optional[fsspec.AbstractFileSystem] = None file_path: str, fs: Optional[fsspec.AbstractFileSystem] = None
) -> Dict: ) -> Dict:
"""Get some handy metadate from filesystem. """Get some handy metadata from filesystem.
Args: Args:
file_path: str: file path in str file_path: str: file path in str
""" """
fs = fs or get_default_fs() fs = fs or get_default_fs()
stat_result = fs.stat(file_path) stat_result = fs.stat(file_path)
file_name = os.path.basename(str(stat_result["name"]))
try:
file_name = os.path.basename(str(stat_result["name"]))
except Exception as e:
file_name = os.path.basename(file_path)
creation_date = _format_file_timestamp(stat_result.get("created")) creation_date = _format_file_timestamp(stat_result.get("created"))
last_modified_date = _format_file_timestamp(stat_result.get("mtime")) last_modified_date = _format_file_timestamp(stat_result.get("mtime"))
last_accessed_date = _format_file_timestamp(stat_result.get("atime")) last_accessed_date = _format_file_timestamp(stat_result.get("atime"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment