prepare for release

This commit is contained in:
Ben Sarmiento
2023-10-20 18:40:13 +02:00
parent 9dcdb60ae7
commit cd6b94f868
4 changed files with 157 additions and 17 deletions

View File

@@ -297,6 +297,15 @@ func (t *TorrentManager) writeToFile(torrentID string, torrent *Torrent) {
func (t *TorrentManager) readFromFile(torrentID string) *Torrent {
filePath := fmt.Sprintf("data/%s.bin", torrentID)
fileInfo, err := os.Stat(filePath)
if err != nil {
return nil
}
if time.Since(fileInfo.ModTime()) > time.Duration(t.config.GetCacheTimeHours())*time.Hour {
return nil
}
file, err := os.Open(filePath)
if err != nil {
return nil