Compare commits

..

No commits in common. "0574e3ec2f200c0dc0630088d99bc0176a11c391" and "96189ef1bf864625b6cf4e7e4b03678cefaa5cce" have entirely different histories.

2 changed files with 21 additions and 4 deletions

View File

@ -11,7 +11,7 @@ import (
) )
var ( var (
PollRate = envvars.Object("POLL_RATE", 30*time.Minute, time.ParseDuration) PollRate = envvars.Duration("POLL_RATE", 30*time.Minute)
AnilistUsername = envvars.String("ANILIST_USERNAME", "username") AnilistUsername = envvars.String("ANILIST_USERNAME", "username")
AnilistAccessToken = envvars.String("ANILIST_TOKEN", "") AnilistAccessToken = envvars.String("ANILIST_TOKEN", "")
@ -70,7 +70,13 @@ var (
/* /*
TODO TODO
better idea? implementation in torrent_sort.go (sort.Slice)
PreferredTorrents = envvars.StringSlice("PREFERRED_TORRENTS", []string{"seeders", "subtitles", "languages", "downloads"})
old idea?
PreferMoreLanguages = envvars.Bool("PREFERER_MORE_LANGUAGES", false) PreferMoreLanguages = envvars.Bool("PREFERER_MORE_LANGUAGES", false)
PreferMoreSubtitles = envvars.Bool("PREFERER_MORE_SUBTITLES", false) PreferMoreSubtitles = envvars.Bool("PREFERER_MORE_SUBTITLES", false)
PreferMoreSeeders = envvars.Bool("PREFERER_MORE_SEEDERS", false)
PreferMoreDownloads = envvars.Bool("PREFERER_MORE_DOWNLOADS", false)
*/ */
) )

View File

@ -18,9 +18,20 @@ type FileProperties struct {
var _ model.PropertyHolder = &FileProperties{} var _ model.PropertyHolder = &FileProperties{}
// TODO cache var filePropCache = map[string]*FileProperties{}
func AnalyzeFile(path string) (*FileProperties, error) {
props := &FileProperties{Filepath: path} func AnalyzeFile(path string) (props *FileProperties, err error) {
// caching
if cacheEntry, ok := filePropCache[path]; ok {
return cacheEntry, nil
}
defer func() {
if err == nil {
filePropCache[path] = props
}
}()
props = &FileProperties{Filepath: path}
file, err := os.Open(path) file, err := os.Open(path)
if err != nil { if err != nil {