Files
Mitchell-JohnsonandClaude Fable 5.1 af189b1fa1 internal/thumbs is internal/media, with Inspect: what a file holds, from ffprobe
The package was named for its first job; it now also decides what a file is for the
Files tab (image, video, audio) and reads its streams, which the viewer will need. Inspect
is the richer probe — codec, profile, pixel format, size, frame rate, HDR transfer, the
audio beside it, container and duration — run as root through sudo when asked.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-11 16:54:15 -07:00

27 lines
527 B
Go

package media
import (
"fmt"
"os"
"os/user"
"strconv"
"syscall"
)
// ownerOf is "root:render 0660" for a device node, the thing to say when it cannot be opened.
func ownerOf(st os.FileInfo) string {
sys, ok := st.Sys().(*syscall.Stat_t)
if !ok {
return ""
}
u := strconv.Itoa(int(sys.Uid))
if x, err := user.LookupId(u); err == nil {
u = x.Username
}
g := strconv.Itoa(int(sys.Gid))
if x, err := user.LookupGroupId(g); err == nil {
g = x.Name
}
return fmt.Sprintf("%s:%s %04o", u, g, st.Mode().Perm())
}