File now produces an error'd icon for an erroneous file

This commit is contained in:
Sasha Koshka 2023-03-23 20:57:51 -04:00
parent 8447b06641
commit fff5ad4d96
2 changed files with 5 additions and 6 deletions

View File

@ -128,8 +128,7 @@ func (element *Directory) Update () error {
element.children = make([]fileLayoutEntry, len(entries))
for index, entry := range entries {
filePath := filepath.Join(location, entry.Name())
file, err := NewFile(filePath, filesystem)
if err != nil { continue }
file, _ := NewFile(filePath, filesystem)
file.SetParent(element)
file.OnChoose (func () {
if element.onChoose != nil {

View File

@ -69,14 +69,14 @@ func (element *File) SetLocation (
// Update refreshes the element to match the file it represents.
func (element *File) Update () error {
element.iconID = theme.IconError
info, err := element.filesystem.Stat(element.location)
if err != nil { return err }
// TODO: choose icon based on file mime type
if info.IsDir() {
if err != nil {
element.iconID = theme.IconError
} else if info.IsDir() {
element.iconID = theme.IconDirectory
} else {
// TODO: choose icon based on file mime type
element.iconID = theme.IconFile
}