From e700f6974e68e388540355d75783520dc1f918a0 Mon Sep 17 00:00:00 2001 From: tauraamui Date: Tue, 16 Sep 2025 14:43:18 +0100 Subject: [PATCH] chore(filepicker): adjust filepickers too big file check to take mock ab --- .../tui/components/dialogs/filepicker/filepicker.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/tui/components/dialogs/filepicker/filepicker.go b/internal/tui/components/dialogs/filepicker/filepicker.go index fcec2fc8b6e3e606e555c55949049f397a30f921..62f7bad59d4d0db7139146b08dc75daad1dc8438 100644 --- a/internal/tui/components/dialogs/filepicker/filepicker.go +++ b/internal/tui/components/dialogs/filepicker/filepicker.go @@ -2,6 +2,7 @@ package filepicker import ( "fmt" + "io/fs" "net/http" "os" "path/filepath" @@ -246,8 +247,16 @@ func (m *model) Position() (int, int) { return row, col } +func IsFileTooBigWithFS(fsys fs.FS, filePath string, sizeLimit int64) (bool, error) { + return isFileTooBigFS(fsys, filePath, sizeLimit) +} + func IsFileTooBig(filePath string, sizeLimit int64) (bool, error) { - fileInfo, err := os.Stat(filePath) + return isFileTooBigFS(os.DirFS("."), filePath, sizeLimit) +} + +func isFileTooBigFS(fsys fs.FS, filePath string, sizeLimit int64) (bool, error) { + fileInfo, err := fs.Stat(fsys, filePath) if err != nil { return false, fmt.Errorf("error getting file info: %w", err) }