Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions backend/file_management/file_management_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
kirtimanmishrazipstack marked this conversation as resolved.

file_content_type = file_info.get("ContentType")
if not file_content_type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? <Document /> : <Folder />;
Expand Down
Loading