diff --git a/backend/file_management/file_management_helper.py b/backend/file_management/file_management_helper.py index ab56c4dba5..008368d09d 100644 --- a/backend/file_management/file_management_helper.py +++ b/backend/file_management/file_management_helper.py @@ -81,9 +81,18 @@ def get_files(fs: AbstractFileSystem, file_path: str) -> list[FileInformation]: if os.path.normpath(file_path) == os.path.normpath(file_name): continue - # Call fs.info() to get file size if its missing + # Google-native docs (Docs/Sheets/Slides) carry no fileSize, so pydrive2's + # info() raises on int(None); fall back to 0 (display-only) to keep listing. if file_info.get("type") == "file" and file_info.get("size") is None: - file_info = fs.info(file_name) + try: + file_info = fs.info(file_name) + except Exception as exc: + logger.warning( + "fs.info() failed for %s; using ls() metadata: %s", + file_name, + exc, + ) + file_info["size"] = 0 file_content_type = file_info.get("ContentType") if not file_content_type: diff --git a/frontend/src/components/input-output/file-system/FileSystem.jsx b/frontend/src/components/input-output/file-system/FileSystem.jsx index 2ce90ef485..3380abcde9 100644 --- a/frontend/src/components/input-output/file-system/FileSystem.jsx +++ b/frontend/src/components/input-output/file-system/FileSystem.jsx @@ -204,7 +204,8 @@ function transformTree(tree) { title = key.split("/").at(-1); isFile = node.type === "file"; modifiedDate = node.modified_at?.split(" ")[0] || ""; - size = isFile ? formatBytes(node.size) : ""; + // Blank when size is 0/unknown (e.g. Google-native docs) instead of "0 B". + size = isFile && node.size ? formatBytes(node.size) : ""; node["key"] = key; node["icon"] = isFile ? : ;