Documentation
¶
Index ¶
- Constants
- Variables
- func CanEditOnlyOffice(modify bool, extention string) bool
- func CouldHaveAlbumArt(extension string) bool
- func DetectTypeByHeader(realPath string) string
- func ExtendedMimeTypeCheck(extension string) string
- func HasAlbumArt(filePath string, extension string) bool
- func HasDocConvertableExtension(name, mimetype string) bool
- func Is3DModel(extension string) bool
- func IsArchive(extension string) bool
- func IsDirectory(fileInfo os.FileInfo) bool
- func IsDoc(extension string) bool
- func IsMatchingDetectedType(detectedType string, extension string, matchType string) bool
- func IsMatchingType(extension string, matchType string) bool
- func IsOnlyOffice(name string) bool
- func IsRawImage(extension string) bool
- func IsText(extension string) bool
- func Model3DMimeType(extension string) string
- func RawImageMimeType(extension string) string
- func ResolveSymlinks(path string) (string, bool, error)
- func ShouldBubbleUpToFolderPreview(item ItemInfo) bool
- func ToInt(str string) int
- func UpdateSize(given string) int
- type ExtendedFileInfo
- type ExtendedItemInfo
- type FFProbeOutput
- type FileInfo
- type ItemInfo
- type MediaMetadata
- type SearchOptions
Constants ¶
const (
LargeFileSizeThreshold = 75 * 1024 * 1024 // 75MB
)
Variables ¶
var AllFiletypeOptions = []string{
"image",
"audio",
"archive",
"video",
"doc",
"text",
}
var BundleExtensions = map[string]bool{ ".app": true, ".bundle": true, ".framework": true, ".plugin": true, ".kext": true, ".pkg": true, ".mpkg": true, ".apk": true, ".aab": true, ".appx": true, ".msix": true, ".deb": true, ".snap": true, ".flatpak": true, ".dmg": true, ".iso": true, }
Known bundle-style extensions that are technically directories but treated as files
var MuPdfConvertable = map[string]bool{ ".pdf": true, ".xps": true, ".epub": true, ".mobi": true, ".fb2": true, ".cbz": true, ".svg": true, ".txt": true, ".docx": true, ".pptx": true, ".xlsx": true, ".hwp": true, ".hwpx": true, ".md": true, }
var ONLYOFFICE_READONLY_FILE_EXTENSIONS = map[string]bool{ "pages": true, "numbers": true, "key": true, }
Functions ¶
func CanEditOnlyOffice ¶
func CouldHaveAlbumArt ¶
func DetectTypeByHeader ¶
DetectTypeByHeader detects the MIME type of a file based on its header.
func ExtendedMimeTypeCheck ¶
func HasAlbumArt ¶
func IsDirectory ¶
IsDirectory determines if a path should be treated as a directory. It treats known bundle-style directories as files instead.
func IsMatchingDetectedType ¶
IsMatchingDetectedType checks if the detected MIME type matches the search type. This uses the actual detected type rather than just the extension, which is more accurate for ambiguous extensions like .ts (TypeScript vs MPEG Transport Stream)
func IsMatchingType ¶
func IsOnlyOffice ¶
func IsRawImage ¶
IsRawImage reports whether the extension is a known raw camera image format.
func Model3DMimeType ¶
Model3DMimeType returns the MIME type for a 3D model extension, or "" if not a 3D model.
func RawImageMimeType ¶
RawImageMimeType returns the MIME type for a raw image extension, or "" if not raw.
func ResolveSymlinks ¶
ResolveSymlinks resolves symlinks in the given path and returns the final resolved path, whether it's a directory (considering bundle logic), and any error.
func ShouldBubbleUpToFolderPreview ¶
ShouldBubbleUpToFolderPreview checks if a file type should be used for folder previews. Only images, videos, and audio files with album art should bubble up. Text files, office documents, and PDFs should NOT bubble up to folder previews. This ensures consistency between indexing and preview generation.
func UpdateSize ¶
Types ¶
type ExtendedFileInfo ¶
type ExtendedFileInfo struct {
FileInfo
Content string `json:"content,omitempty"` // text content of a file, if requested
Subtitles []utils.SubtitleTrack `json:"subtitles,omitempty"` // subtitles for video files
Metadata *MediaMetadata `json:"metadata,omitempty"` // media metadata for audio/video files (includes duration)
Checksums map[string]string `json:"checksums,omitempty"` // checksums for the file
Token string `json:"token,omitempty"` // token for the file -- used for sharing
OnlyOfficeId string `json:"onlyOfficeId,omitempty"` // id for onlyoffice files
Source string `json:"source,omitempty"` // associated index source for the file
Hash string `json:"hash,omitempty"` // hash for the file -- used for sharing
HasMetadata bool `json:"hasMetadata"` // whether the file or folder has metadata
RealPath string `json:"-"`
}
for efficiency, a response will be a pointer to the data extra calculated fields can be added here
func (*ExtendedFileInfo) GetSubtitles ¶
func (i *ExtendedFileInfo) GetSubtitles(parentInfo *FileInfo)
GetSubtitles detects external subtitle files for video files. Embedded subtitles should be detected by ffmpeg and passed as embeddedSubs parameter.
type ExtendedItemInfo ¶
type ExtendedItemInfo struct {
ItemInfo
Metadata *MediaMetadata `json:"metadata,omitempty"` // optional media metadata (audio/video only)
}
ExtendedItemInfo extends ItemInfo with optional metadata that's only populated on-demand This avoids adding memory overhead to indexed items
type FFProbeOutput ¶
type FileInfo ¶
type FileInfo struct {
ItemInfo
Files []ExtendedItemInfo `json:"files,omitempty"` // files in the directory with optional metadata
Folders []ItemInfo `json:"folders,omitempty"` // folders in the directory
Path string `json:"path,omitempty"` // path scoped to the associated index
}
FileInfo describes a file. reduced item is non-recursive reduced "Items", used to pass flat items array
type ItemInfo ¶
type ItemInfo struct {
Name string `json:"name"` // name of the file
Size int64 `json:"size"` // length in bytes for regular files
ModTime time.Time `json:"modified"` // modification time
Type string `json:"type"` // type of the file, either "directory" or a file mimetype
Hidden bool `json:"hidden"` // whether the file is hidden
HasPreview bool `json:"hasPreview"` // whether the file has a thumbnail preview
}
func (ItemInfo) ContainsSearchTerm ¶
func (fi ItemInfo) ContainsSearchTerm(searchTerm string, options SearchOptions) bool
returns true if the file name contains the search term returns file type if the file name contains the search term returns size of file/dir if the file name contains the search term
func (*ItemInfo) DetectType ¶
DetectType detects the MIME type of a file and updates the ItemInfo struct.
type MediaMetadata ¶
type MediaMetadata struct {
Title string `json:"title,omitempty"` // track/video title
Artist string `json:"artist,omitempty"` // track artist
Album string `json:"album,omitempty"` // album name
Year int `json:"year,omitempty"` // release year
Genre string `json:"genre,omitempty"` // music/video genre
Track int `json:"track,omitempty"` // track number
Duration int `json:"duration,omitempty"` // duration in seconds
AlbumArt []byte `json:"albumArt,omitempty"` // album art image data (automatically base64-encoded in JSON)
}
MediaMetadata contains metadata extracted from audio and video files
type SearchOptions ¶
type SearchOptions struct {
Conditions map[string]bool
LargerThan int
SmallerThan int
Terms []string
}
func ParseSearch ¶
func ParseSearch(value string) SearchOptions