finalize beta-0.4.1
This commit is contained in:
2
go.mod
2
go.mod
@@ -15,6 +15,7 @@ require (
|
||||
github.com/rs/zerolog v1.33.0
|
||||
github.com/valyala/fastjson v1.6.4
|
||||
golang.org/x/crypto v0.33.0
|
||||
golang.org/x/net v0.33.0
|
||||
golang.org/x/time v0.8.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
)
|
||||
@@ -32,7 +33,6 @@ require (
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
||||
github.com/stretchr/testify v1.10.0 // indirect
|
||||
golang.org/x/net v0.33.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
)
|
||||
|
||||
@@ -133,9 +133,7 @@ func (q *QBit) downloadFiles(torrent *Torrent, parent string) {
|
||||
|
||||
func (q *QBit) ProcessSymlink(torrent *Torrent) (string, error) {
|
||||
debridTorrent := torrent.DebridTorrent
|
||||
var wg sync.WaitGroup
|
||||
files := debridTorrent.Files
|
||||
ready := make(chan debrid.File, len(files))
|
||||
if len(files) == 0 {
|
||||
return "", fmt.Errorf("no video files found")
|
||||
}
|
||||
@@ -159,19 +157,24 @@ func (q *QBit) ProcessSymlink(torrent *Torrent) (string, error) {
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create directory: %s: %v", torrentSymlinkPath, err)
|
||||
}
|
||||
|
||||
pending := make(map[string]debrid.File)
|
||||
for _, file := range files {
|
||||
wg.Add(1)
|
||||
go checkFileLoop(&wg, torrentRclonePath, file, ready)
|
||||
pending[file.Path] = file
|
||||
}
|
||||
ticker := time.NewTicker(200 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(ready)
|
||||
}()
|
||||
|
||||
for f := range ready {
|
||||
q.logger.Info().Msgf("File is ready: %s", f.Path)
|
||||
q.createSymLink(torrentSymlinkPath, torrentRclonePath, f)
|
||||
for len(pending) > 0 {
|
||||
<-ticker.C
|
||||
for path, file := range pending {
|
||||
fullFilePath := filepath.Join(torrentRclonePath, file.Path)
|
||||
if _, err := os.Stat(fullFilePath); !os.IsNotExist(err) {
|
||||
q.logger.Info().Msgf("File is ready: %s", file.Path)
|
||||
q.createSymLink(torrentSymlinkPath, torrentRclonePath, file)
|
||||
delete(pending, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
return torrentSymlinkPath, nil
|
||||
}
|
||||
@@ -183,7 +186,7 @@ func (q *QBit) getTorrentPath(rclonePath string, debridTorrent *debrid.Torrent)
|
||||
q.logger.Debug().Msgf("Found torrent path: %s", torrentPath)
|
||||
return torrentPath, err
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,6 +198,7 @@ func (q *QBit) createSymLink(path string, torrentMountPath string, file debrid.F
|
||||
torrentFilePath := filepath.Join(torrentMountPath, file.Path) // debridFolder/MyTVShow/MyTVShow.S01E01.720p.mkv
|
||||
err := os.Symlink(torrentFilePath, fullPath)
|
||||
if err != nil {
|
||||
q.logger.Info().Msgf("Failed to create symlink: %s: %v", fullPath, err)
|
||||
// It's okay if the symlink already exists
|
||||
q.logger.Debug().Msgf("Failed to create symlink: %s: %v", fullPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Install FUSE and required dependencies
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends fuse3
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create nonroot user and group
|
||||
groupadd -r nonroot
|
||||
useradd -r -g nonroot nonroot
|
||||
|
||||
# Create mount directory
|
||||
mkdir -p /mnt/rclone
|
||||
chown nonroot:nonroot /mnt/rclone
|
||||
Reference in New Issue
Block a user