|
|
@ -2,12 +2,14 @@ package service
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
|
|
|
"net/url"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"path"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
|
|
|
|
stringy "github.com/gobeam/stringy"
|
|
|
|
stringy "github.com/gobeam/stringy"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -33,8 +35,19 @@ func Download(link string, episodeTitle string, podcastName string) (string, err
|
|
|
|
if erra != nil {
|
|
|
|
if erra != nil {
|
|
|
|
return "", erra
|
|
|
|
return "", erra
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
changeOwnership(finalPath)
|
|
|
|
return finalPath, nil
|
|
|
|
return finalPath, nil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func changeOwnership(path string) {
|
|
|
|
|
|
|
|
uid, err1 := strconv.Atoi(os.Getenv("PUID"))
|
|
|
|
|
|
|
|
gid, err2 := strconv.Atoi(os.Getenv("PGID"))
|
|
|
|
|
|
|
|
fmt.Println(path)
|
|
|
|
|
|
|
|
if err1 == nil && err2 == nil {
|
|
|
|
|
|
|
|
fmt.Println(path + " : Attempting change")
|
|
|
|
|
|
|
|
os.Chown(path, uid, gid)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func DeleteFile(filePath string) error {
|
|
|
|
func DeleteFile(filePath string) error {
|
|
|
|
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
|
|
|
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
|
|
@ -63,6 +76,7 @@ func createIfFoldeDoesntExist(folder string) string {
|
|
|
|
folderPath := path.Join(dataPath, folder)
|
|
|
|
folderPath := path.Join(dataPath, folder)
|
|
|
|
if _, err := os.Stat(folderPath); os.IsNotExist(err) {
|
|
|
|
if _, err := os.Stat(folderPath); os.IsNotExist(err) {
|
|
|
|
os.MkdirAll(folderPath, 0777)
|
|
|
|
os.MkdirAll(folderPath, 0777)
|
|
|
|
|
|
|
|
changeOwnership(folderPath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return folderPath
|
|
|
|
return folderPath
|
|
|
|
}
|
|
|
|
}
|
|
|
|