qbittorrent fs

This commit is contained in:
royalcat 2024-09-01 02:00:13 +03:00
parent ae4501ae21
commit f75188b412
51 changed files with 4048 additions and 231 deletions
cmd/tstor

View file

@ -20,7 +20,7 @@ import (
"git.kmsign.ru/royalcat/tstor/src/config"
"git.kmsign.ru/royalcat/tstor/src/delivery"
"git.kmsign.ru/royalcat/tstor/src/sources"
"git.kmsign.ru/royalcat/tstor/src/sources/torrent"
"git.kmsign.ru/royalcat/tstor/src/sources/qbittorrent"
"git.kmsign.ru/royalcat/tstor/src/sources/ytdlp"
"git.kmsign.ru/royalcat/tstor/src/telemetry"
"git.kmsign.ru/royalcat/tstor/src/vfs"
@ -91,10 +91,10 @@ func run(configPath string) error {
}
sourceFs := osfs.New(conf.SourceDir, osfs.WithBoundOS())
tsrv, err := torrent.NewDaemon(sourceFs, conf.TorrentClient)
if err != nil {
return fmt.Errorf("error creating service: %w", err)
}
// tsrv, err := torrent.NewDaemon(sourceFs, conf.Sources.TorrentClient)
// if err != nil {
// return fmt.Errorf("error creating service: %w", err)
// }
err = os.MkdirAll("./ytdlp", 0744)
if err != nil {
@ -105,9 +105,14 @@ func run(configPath string) error {
return err
}
qtsrv, err := qbittorrent.NewDaemon(conf.Sources.QBittorrent)
if err != nil {
return fmt.Errorf("error creating qbittorrent daemon: %w", err)
}
sfs := sources.NewHostedFS(
vfs.NewCtxBillyFs("/", ctxbilly.WrapFileSystem(sourceFs)),
tsrv, ytdlpsrv,
qtsrv, ytdlpsrv,
)
sfs, err = vfs.WrapLogFS(sfs)
if err != nil {
@ -187,7 +192,7 @@ func run(configPath string) error {
go func() {
logFilename := filepath.Join(conf.Log.Path, "logs")
err := delivery.Run(tsrv, sfs, logFilename, conf)
err := delivery.Run(nil, sfs, logFilename, conf)
if err != nil {
log.Error(ctx, "error initializing HTTP server", rlog.Error(err))
}
@ -198,6 +203,7 @@ func run(configPath string) error {
<-sigChan
return errors.Join(
tsrv.Close(ctx),
// tsrv.Close(ctx),
qtsrv.Close(ctx),
)
}