downloader/local_file_check.go

32 lines
633 B
Go
Raw Normal View History

package main
import (
2022-08-23 11:48:26 +02:00
"errors"
"os"
"path/filepath"
"git.milar.in/nyaanime/logic"
"git.milar.in/nyaanime/model"
)
2022-08-23 13:24:03 +02:00
func IsCurrentlyDownloading(animeEp model.AnimeEpisode) bool {
animeEpPath := logic.GetAnimeEpFilepath(animeEp, "lock")
2022-08-23 11:48:26 +02:00
_, err := os.Stat(animeEpPath)
return !errors.Is(err, os.ErrNotExist)
}
2022-08-23 13:24:03 +02:00
func SetCurrentlyDownloading(animeEp model.AnimeEpisode) error {
animeEpPath := logic.GetAnimeEpFilepath(animeEp, "lock")
2022-08-25 23:25:48 +02:00
dir := filepath.Dir(animeEpPath)
if err := os.MkdirAll(dir, 0755); err != nil {
return err
}
2022-08-23 11:48:26 +02:00
file, err := os.Create(animeEpPath)
if err != nil {
defer file.Close()
}
2022-08-23 11:48:26 +02:00
return err
}