initial commit
This commit is contained in:
31
local_file_check.go
Normal file
31
local_file_check.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"git.tordarus.net/nyaanime/logic"
|
||||
"git.tordarus.net/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
|
||||
}
|
Reference in New Issue
Block a user