package main import ( "errors" "os" "path/filepath" "git.milar.in/nyaanime/logic" "git.milar.in/nyaanime/model" ) func IsCurrentlyDownloading(animeEp model.AnimeEpisode) bool { animeEpPath := logic.GetAnimeEpFilepath(animeEp, "lock") _, err := os.Stat(animeEpPath) return !errors.Is(err, os.ErrNotExist) } func SetCurrentlyDownloading(animeEp model.AnimeEpisode) error { animeEpPath := logic.GetAnimeEpFilepath(animeEp, "lock") dir := filepath.Dir(animeEpPath) if err := os.MkdirAll(dir, 0755); err != nil { return err } file, err := os.Create(animeEpPath) if err != nil { defer file.Close() } return err }