- Add mounting support

- Fix minor issues
This commit is contained in:
Mukhtar Akere
2025-08-04 16:57:09 +01:00
parent a60d93677f
commit 139249a1f3
25 changed files with 1565 additions and 112 deletions

View File

@@ -127,6 +127,21 @@ func (c *Cache) refreshTorrents(ctx context.Context) {
func (c *Cache) refreshRclone() error {
cfg := c.config
dirs := strings.FieldsFunc(cfg.RcRefreshDirs, func(r rune) bool {
return r == ',' || r == '&'
})
if len(dirs) == 0 {
dirs = []string{"__all__"}
}
if c.mounter != nil {
return c.mounter.Refresh(dirs)
} else {
return c.refreshRcloneWithRC(dirs)
}
}
func (c *Cache) refreshRcloneWithRC(dirs []string) error {
cfg := c.config
if cfg.RcUrl == "" {
return nil
@@ -138,7 +153,7 @@ func (c *Cache) refreshRclone() error {
client := http.DefaultClient
// Create form data
data := c.buildRcloneRequestData()
data := c.buildRcloneRequestData(dirs)
if err := c.sendRcloneRequest(client, "vfs/forget", data); err != nil {
c.logger.Error().Err(err).Msg("Failed to send rclone vfs/forget request")
@@ -151,16 +166,7 @@ func (c *Cache) refreshRclone() error {
return nil
}
func (c *Cache) buildRcloneRequestData() string {
cfg := c.config
dirs := strings.FieldsFunc(cfg.RcRefreshDirs, func(r rune) bool {
return r == ',' || r == '&'
})
if len(dirs) == 0 {
return "dir=__all__"
}
func (c *Cache) buildRcloneRequestData(dirs []string) string {
var data strings.Builder
for index, dir := range dirs {
if dir != "" {