diff --git a/internal/config/config.go b/internal/config/config.go index 75c3ca0..5c9d885 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -105,7 +105,6 @@ type Rclone struct { VfsReadChunkSize string `json:"vfs_read_chunk_size,omitempty"` // Read chunk size (default 128M) VfsReadChunkSizeLimit string `json:"vfs_read_chunk_size_limit,omitempty"` // Max chunk size (default off) VfsReadAhead string `json:"vfs_read_ahead,omitempty"` // read ahead size - VfsPollInterval string `json:"vfs_poll_interval,omitempty"` // How often to rclone cleans the cache (default 1m) BufferSize string `json:"buffer_size,omitempty"` // Buffer size for reading files (default 16M) VfsCacheMinFreeSpace string `json:"vfs_cache_min_free_space,omitempty"` diff --git a/pkg/arr/arr.go b/pkg/arr/arr.go index 1b16720..21c549c 100644 --- a/pkg/arr/arr.go +++ b/pkg/arr/arr.go @@ -6,15 +6,16 @@ import ( "crypto/tls" "encoding/json" "fmt" - "github.com/rs/zerolog" - "github.com/sirrobot01/decypharr/internal/config" - "github.com/sirrobot01/decypharr/internal/logger" - "github.com/sirrobot01/decypharr/internal/request" "io" "net/http" "strings" "sync" "time" + + "github.com/rs/zerolog" + "github.com/sirrobot01/decypharr/internal/config" + "github.com/sirrobot01/decypharr/internal/logger" + "github.com/sirrobot01/decypharr/internal/request" ) // Type is a type of arr @@ -109,7 +110,7 @@ func (a *Arr) Request(method, endpoint string, payload interface{}) (*http.Respo func (a *Arr) Validate() error { if a.Token == "" || a.Host == "" { - return fmt.Errorf("arr not configured: %s", a.Name) + return nil } resp, err := a.Request("GET", "/api/v3/health", nil) if err != nil { diff --git a/pkg/debrid/store/refresh.go b/pkg/debrid/store/refresh.go index c2f3dc4..069c15b 100644 --- a/pkg/debrid/store/refresh.go +++ b/pkg/debrid/store/refresh.go @@ -3,13 +3,14 @@ package store import ( "context" "fmt" - "github.com/sirrobot01/decypharr/pkg/debrid/types" "io" "net/http" "os" "strings" "sync" "time" + + "github.com/sirrobot01/decypharr/pkg/debrid/types" ) type fileInfo struct { @@ -120,7 +121,7 @@ func (c *Cache) refreshTorrents(ctx context.Context) { close(workChan) wg.Wait() - c.listingDebouncer.Call(false) + c.listingDebouncer.Call(true) c.logger.Debug().Msgf("Processed %d new torrents", counter) } diff --git a/pkg/debrid/types/account.go b/pkg/debrid/types/account.go index b095bd8..330d395 100644 --- a/pkg/debrid/types/account.go +++ b/pkg/debrid/types/account.go @@ -1,10 +1,11 @@ package types import ( - "github.com/sirrobot01/decypharr/internal/config" "slices" "sync" "sync/atomic" + + "github.com/sirrobot01/decypharr/internal/config" ) type Accounts struct { @@ -35,7 +36,6 @@ type Account struct { Debrid string // e.g., "realdebrid", "torbox", etc. Order int Disabled bool - InUse bool Token string `json:"token"` links map[string]*DownloadLink mu sync.RWMutex @@ -103,16 +103,6 @@ func (a *Accounts) setCurrent(account *Account) { if account == nil { return } - // Set every account InUse to false - a.accounts.Range(func(key, value interface{}) bool { - acc, ok := value.(*Account) - if ok { - acc.InUse = false - a.accounts.Store(key, acc) - } - return true - }) - account.InUse = true a.current.Store(account) } diff --git a/pkg/rclone/client.go b/pkg/rclone/client.go index 6cb9de2..8dfaced 100644 --- a/pkg/rclone/client.go +++ b/pkg/rclone/client.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "os/exec" + "strconv" "time" "github.com/sirrobot01/decypharr/internal/config" @@ -115,7 +116,8 @@ func (m *Manager) performMount(mountPath, provider, webdavURL string) error { mountArgs["_config"] = configOpts } vfsOpt := map[string]interface{}{ - "CacheMode": cfg.Rclone.VfsCacheMode, + "CacheMode": cfg.Rclone.VfsCacheMode, + "DirCacheTime": cfg.Rclone.DirCacheTime, } vfsOpt["PollInterval"] = 0 // Poll interval not supported for webdav, set to 0 @@ -125,6 +127,13 @@ func (m *Manager) performMount(mountPath, provider, webdavURL string) error { if cfg.Rclone.VfsCacheMaxAge != "" { vfsOpt["CacheMaxAge"] = cfg.Rclone.VfsCacheMaxAge } + if cfg.Rclone.VfsDiskSpaceTotal != "" { + vfsOpt["DiskSpaceTotalSize"] = cfg.Rclone.VfsDiskSpaceTotal + } + if cfg.Rclone.VfsReadChunkSizeLimit != "" { + vfsOpt["ChunkSizeLimit"] = cfg.Rclone.VfsReadChunkSizeLimit + } + if cfg.Rclone.VfsCacheMaxSize != "" { vfsOpt["CacheMaxSize"] = cfg.Rclone.VfsCacheMaxSize } @@ -147,7 +156,7 @@ func (m *Manager) performMount(mountPath, provider, webdavURL string) error { } if cfg.Rclone.VfsReadChunkStreams != 0 { - vfsOpt["ReadChunkStreams"] = cfg.Rclone.VfsReadChunkStreams + vfsOpt["ChunkStreams"] = cfg.Rclone.VfsReadChunkStreams } if cfg.Rclone.NoChecksum { @@ -160,11 +169,19 @@ func (m *Manager) performMount(mountPath, provider, webdavURL string) error { // Add mount options based on configuration if cfg.Rclone.UID != 0 { - mountOpt["UID"] = cfg.Rclone.UID + vfsOpt["UID"] = cfg.Rclone.UID } if cfg.Rclone.GID != 0 { - mountOpt["GID"] = cfg.Rclone.GID + vfsOpt["GID"] = cfg.Rclone.GID } + + if cfg.Rclone.Umask != "" { + umask, err := strconv.ParseInt(cfg.Rclone.Umask, 8, 32) + if err == nil { + vfsOpt["Umask"] = uint32(umask) + } + } + if cfg.Rclone.AttrTimeout != "" { if attrTimeout, err := time.ParseDuration(cfg.Rclone.AttrTimeout); err == nil { mountOpt["AttrTimeout"] = attrTimeout.String() @@ -182,7 +199,7 @@ func (m *Manager) performMount(mountPath, provider, webdavURL string) error { _, err := m.makeRequest(req, true) if err != nil { // Clean up mount point on failure - m.forceUnmountPath(mountPath) + _ = m.forceUnmountPath(mountPath) return fmt.Errorf("failed to create mount for %s: %w", provider, err) } diff --git a/pkg/rclone/mount.go b/pkg/rclone/mount.go index 2c0b9d3..6359868 100644 --- a/pkg/rclone/mount.go +++ b/pkg/rclone/mount.go @@ -3,11 +3,12 @@ package rclone import ( "context" "fmt" - "github.com/rs/zerolog" - "github.com/sirrobot01/decypharr/internal/config" "net/url" "path/filepath" "strings" + + "github.com/rs/zerolog" + "github.com/sirrobot01/decypharr/internal/config" ) // Mount represents a mount using the rclone RC client diff --git a/pkg/server/debug.go b/pkg/server/debug.go index c889463..2ed14c7 100644 --- a/pkg/server/debug.go +++ b/pkg/server/debug.go @@ -136,7 +136,6 @@ func (s *Server) handleStats(w http.ResponseWriter, r *http.Request) { accountDetail := map[string]any{ "order": account.Order, "disabled": account.Disabled, - "in_use": account.InUse, "token_masked": maskedToken, "username": account.Username, "traffic_used": account.TrafficUsed, diff --git a/pkg/web/templates/stats.html b/pkg/web/templates/stats.html index 9163a76..2e66108 100644 --- a/pkg/web/templates/stats.html +++ b/pkg/web/templates/stats.html @@ -371,10 +371,6 @@ const statusBadge = account.disabled ? 'Disabled' : 'Active'; - - const inUseBadge = account.in_use ? - 'In Use' : - ''; html += `