82 session file location (#91)

* change session file location

* makefile refactor

* gha refactor
This commit is contained in:
Marco
2023-09-26 10:25:14 +02:00
committed by GitHub
parent 8337aae438
commit 4710db25ee
5 changed files with 32 additions and 19 deletions

View File

@@ -76,5 +76,5 @@ jobs:
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: |
cosign sign ghcr.io/${{ github.repository }}@${{ steps.build-and-push.outputs.digest }}
cosign sign docker.io/${{ secrets.DOCKER_HUB_USERNAME }}/yt-dlp-webui@${{ steps.build-and-push.outputs.digest }}
cosign sign ghcr.io/${{ github.repository }}:latest
cosign sign docker.io/${{ secrets.DOCKER_HUB_USERNAME }}/yt-dlp-webui:latest

View File

@@ -6,11 +6,10 @@ all:
CGO_ENABLED=0 go build -o yt-dlp-webui main.go
multiarch:
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o yt-dlp-webui_linux-arm main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o yt-dlp-webui_linux-arm64 main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o yt-dlp-webui_linux-amd64 main.go
mkdir -p build
mv yt-dlp-webui* build
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o build/yt-dlp-webui_linux-arm main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o build/yt-dlp-webui_linux-arm64 main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/yt-dlp-webui_linux-amd64 main.go
clean:
rm -rf build

12
main.go
View File

@@ -14,11 +14,12 @@ import (
)
var (
port int
queueSize int
configFile string
downloadPath string
downloaderPath string
port int
queueSize int
configFile string
downloadPath string
downloaderPath string
sessionFilePath string
requireAuth bool
username string
@@ -40,6 +41,7 @@ func init() {
flag.StringVar(&configFile, "conf", "./config.yml", "Config file path")
flag.StringVar(&downloadPath, "out", ".", "Where files will be saved")
flag.StringVar(&downloaderPath, "driver", "yt-dlp", "yt-dlp executable path")
flag.StringVar(&sessionFilePath, "session", ".", "session file path")
flag.BoolVar(&requireAuth, "auth", false, "Enable RPC authentication")
flag.StringVar(&username, "user", userFromEnv, "Username required for auth")

View File

@@ -10,13 +10,14 @@ import (
var lock sync.Mutex
type serverConfig struct {
Port int `yaml:"port"`
DownloadPath string `yaml:"downloadPath"`
DownloaderPath string `yaml:"downloaderPath"`
RequireAuth bool `yaml:"require_auth"`
Username string `yaml:"username"`
Password string `yaml:"password"`
QueueSize int `yaml:"queue_size"`
Port int `yaml:"port"`
DownloadPath string `yaml:"downloadPath"`
DownloaderPath string `yaml:"downloaderPath"`
RequireAuth bool `yaml:"require_auth"`
Username string `yaml:"username"`
Password string `yaml:"password"`
QueueSize int `yaml:"queue_size"`
SessionFilePath string `yaml:"session_file_path"`
}
type config struct {
@@ -68,6 +69,10 @@ func (c *config) QueueSize(size int) {
c.cfg.QueueSize = size
}
func (c *config) SessionFilePath(path string) {
c.cfg.SessionFilePath = path
}
var instance *config
func Instance() *config {

View File

@@ -6,10 +6,12 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"sync"
"github.com/google/uuid"
"github.com/marcopeocchi/yt-dlp-web-ui/server/cli"
"github.com/marcopeocchi/yt-dlp-web-ui/server/config"
)
// In-Memory Thread-Safe Key-Value Storage with optional persistence
@@ -93,7 +95,12 @@ func (m *MemoryDB) All() *[]ProcessResponse {
func (m *MemoryDB) Persist() {
running := m.All()
fd, err := os.Create("session.dat")
sessionFile := filepath.Join(
config.Instance().GetConfig().SessionFilePath,
"session.dat",
)
fd, err := os.Create(sessionFile)
if err != nil {
log.Println(cli.Red, "Failed to persist session", cli.Reset)
}