improve space management
This commit is contained in:
parent
8c349cf7ac
commit
b5c9806dd0
2 changed files with 12 additions and 0 deletions
|
@ -295,6 +295,7 @@ func (s *Sync) FullCycle() (e error) {
|
||||||
return errors.Wrap(err, 0)
|
return errors.Wrap(err, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer deleteSyncFolder(s.videoDirectory)
|
||||||
log.Printf("Starting daemon")
|
log.Printf("Starting daemon")
|
||||||
err = startDaemonViaSystemd()
|
err = startDaemonViaSystemd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -323,6 +324,16 @@ func (s *Sync) FullCycle() (e error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteSyncFolder(videoDirectory string) {
|
||||||
|
if !strings.Contains(videoDirectory, "/tmp/ytsync") {
|
||||||
|
_ = util.SendToSlack(errors.Err("Trying to delete an unexpected directory: %s", videoDirectory).Error())
|
||||||
|
}
|
||||||
|
err := os.RemoveAll(videoDirectory)
|
||||||
|
if err != nil {
|
||||||
|
_ = util.SendToSlack(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Sync) setChannelTerminationStatus(e *error) {
|
func (s *Sync) setChannelTerminationStatus(e *error) {
|
||||||
if *e != nil {
|
if *e != nil {
|
||||||
//conditions for which a channel shouldn't be marked as failed
|
//conditions for which a channel shouldn't be marked as failed
|
||||||
|
|
|
@ -187,6 +187,7 @@ func (v *YoutubeVideo) fallbackDownload() error {
|
||||||
log.Debugln(string(output))
|
log.Debugln(string(output))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Command finished with error: %v", errors.Err(string(output)))
|
log.Printf("Command finished with error: %v", errors.Err(string(output)))
|
||||||
|
_ = v.delete()
|
||||||
return errors.Err(err)
|
return errors.Err(err)
|
||||||
}
|
}
|
||||||
fi, err := os.Stat(v.getFullPath())
|
fi, err := os.Stat(v.getFullPath())
|
||||||
|
|
Loading…
Reference in a new issue