Compare commits

...

2 Commits

Author SHA1 Message Date
Timon Ringwald
0574e3ec2f removed unused env vars 2022-08-26 18:28:14 +02:00
Timon Ringwald
c4af5f9e97 Revert "fileprop cache"
This reverts commit 96189ef1bf.
2022-08-26 18:27:54 +02:00
2 changed files with 4 additions and 21 deletions

View File

@ -11,7 +11,7 @@ import (
) )
var ( var (
PollRate = envvars.Duration("POLL_RATE", 30*time.Minute) PollRate = envvars.Object("POLL_RATE", 30*time.Minute, time.ParseDuration)
AnilistUsername = envvars.String("ANILIST_USERNAME", "username") AnilistUsername = envvars.String("ANILIST_USERNAME", "username")
AnilistAccessToken = envvars.String("ANILIST_TOKEN", "") AnilistAccessToken = envvars.String("ANILIST_TOKEN", "")
@ -70,13 +70,7 @@ 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,20 +18,9 @@ type FileProperties struct {
var _ model.PropertyHolder = &FileProperties{} var _ model.PropertyHolder = &FileProperties{}
var filePropCache = map[string]*FileProperties{} // TODO cache
func AnalyzeFile(path string) (*FileProperties, error) {
func AnalyzeFile(path string) (props *FileProperties, err error) { props := &FileProperties{Filepath: path}
// 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 {