fix(columns): hide misleading directory sizes (#87)

* fix(columns): hide misleading directory sizes in size column

Problem: the size column shows the filesystem inode size (typically
4096 = 4.1k) for directories, which is misleading — users expect no
size for directories.

Solution: add an early return for directory entries in the size render
function of the files, SSH, and S3 adapters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs(upstream): mark #486 fixed

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Barrett Ruth 2026-03-08 15:31:43 -04:00 committed by GitHub
parent abc4879688
commit fc43684bbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 3 deletions

View file

@ -60,6 +60,9 @@ file_columns.size = {
if not stat then
return columns.EMPTY
end
if entry[FIELD_TYPE] == 'directory' then
return columns.EMPTY
end
if stat.size >= 1e9 then
return string.format('%.1fG', stat.size / 1e9)
elseif stat.size >= 1e6 then

View file

@ -8,6 +8,7 @@ local s3fs = require('canola.adapters.s3.s3fs')
local util = require('canola.util')
local M = {}
local FIELD_TYPE = constants.FIELD_TYPE
local FIELD_META = constants.FIELD_META
---@class (exact) canola.s3Url
@ -84,7 +85,11 @@ s3_columns.size = {
local meta = entry[FIELD_META]
if not meta or not meta.size then
return ''
elseif meta.size >= 1e9 then
end
if entry[FIELD_TYPE] == 'directory' then
return ''
end
if meta.size >= 1e9 then
return string.format('%.1fG', meta.size / 1e9)
elseif meta.size >= 1e6 then
return string.format('%.1fM', meta.size / 1e6)

View file

@ -11,6 +11,7 @@ local util = require('canola.util')
local M = {}
local FIELD_NAME = constants.FIELD_NAME
local FIELD_TYPE = constants.FIELD_TYPE
local FIELD_META = constants.FIELD_META
---@class (exact) canola.sshUrl
@ -152,7 +153,11 @@ ssh_columns.size = {
local meta = entry[FIELD_META]
if not meta or not meta.size then
return ''
elseif meta.size >= 1e9 then
end
if entry[FIELD_TYPE] == 'directory' then
return ''
end
if meta.size >= 1e9 then
return string.format('%.1fG', meta.size / 1e9)
elseif meta.size >= 1e6 then
return string.format('%.1fM', meta.size / 1e6)