82 session file location (#91)
* change session file location * makefile refactor * gha refactor
This commit is contained in:
4
.github/workflows/docker-publish.yml
vendored
4
.github/workflows/docker-publish.yml
vendored
@@ -76,5 +76,5 @@ jobs:
|
|||||||
# This step uses the identity token to provision an ephemeral certificate
|
# This step uses the identity token to provision an ephemeral certificate
|
||||||
# against the sigstore community Fulcio instance.
|
# against the sigstore community Fulcio instance.
|
||||||
run: |
|
run: |
|
||||||
cosign sign ghcr.io/${{ github.repository }}@${{ steps.build-and-push.outputs.digest }}
|
cosign sign ghcr.io/${{ github.repository }}:latest
|
||||||
cosign sign docker.io/${{ secrets.DOCKER_HUB_USERNAME }}/yt-dlp-webui@${{ steps.build-and-push.outputs.digest }}
|
cosign sign docker.io/${{ secrets.DOCKER_HUB_USERNAME }}/yt-dlp-webui:latest
|
||||||
|
|||||||
7
Makefile
7
Makefile
@@ -6,11 +6,10 @@ all:
|
|||||||
CGO_ENABLED=0 go build -o yt-dlp-webui main.go
|
CGO_ENABLED=0 go build -o yt-dlp-webui main.go
|
||||||
|
|
||||||
multiarch:
|
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
|
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:
|
clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
2
main.go
2
main.go
@@ -19,6 +19,7 @@ var (
|
|||||||
configFile string
|
configFile string
|
||||||
downloadPath string
|
downloadPath string
|
||||||
downloaderPath string
|
downloaderPath string
|
||||||
|
sessionFilePath string
|
||||||
|
|
||||||
requireAuth bool
|
requireAuth bool
|
||||||
username string
|
username string
|
||||||
@@ -40,6 +41,7 @@ func init() {
|
|||||||
flag.StringVar(&configFile, "conf", "./config.yml", "Config file path")
|
flag.StringVar(&configFile, "conf", "./config.yml", "Config file path")
|
||||||
flag.StringVar(&downloadPath, "out", ".", "Where files will be saved")
|
flag.StringVar(&downloadPath, "out", ".", "Where files will be saved")
|
||||||
flag.StringVar(&downloaderPath, "driver", "yt-dlp", "yt-dlp executable path")
|
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.BoolVar(&requireAuth, "auth", false, "Enable RPC authentication")
|
||||||
flag.StringVar(&username, "user", userFromEnv, "Username required for auth")
|
flag.StringVar(&username, "user", userFromEnv, "Username required for auth")
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ type serverConfig struct {
|
|||||||
Username string `yaml:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password"`
|
||||||
QueueSize int `yaml:"queue_size"`
|
QueueSize int `yaml:"queue_size"`
|
||||||
|
SessionFilePath string `yaml:"session_file_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
@@ -68,6 +69,10 @@ func (c *config) QueueSize(size int) {
|
|||||||
c.cfg.QueueSize = size
|
c.cfg.QueueSize = size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *config) SessionFilePath(path string) {
|
||||||
|
c.cfg.SessionFilePath = path
|
||||||
|
}
|
||||||
|
|
||||||
var instance *config
|
var instance *config
|
||||||
|
|
||||||
func Instance() *config {
|
func Instance() *config {
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/marcopeocchi/yt-dlp-web-ui/server/cli"
|
"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
|
// In-Memory Thread-Safe Key-Value Storage with optional persistence
|
||||||
@@ -93,7 +95,12 @@ func (m *MemoryDB) All() *[]ProcessResponse {
|
|||||||
func (m *MemoryDB) Persist() {
|
func (m *MemoryDB) Persist() {
|
||||||
running := m.All()
|
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 {
|
if err != nil {
|
||||||
log.Println(cli.Red, "Failed to persist session", cli.Reset)
|
log.Println(cli.Red, "Failed to persist session", cli.Reset)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user