chore(filepicker): adjust filepickers too big file check to take mock ab

tauraamui created

Change summary

internal/tui/components/dialogs/filepicker/filepicker.go | 11 +++++++++
1 file changed, 10 insertions(+), 1 deletion(-)

Detailed changes

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)
 	}