Skip to content

Commit

Permalink
Force connect on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan committed Jul 1, 2024
1 parent 3d32776 commit 7a753b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ require (
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dustin/go-humanize v1.0.1
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/eapache/go-resiliency v1.6.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
Expand Down
14 changes: 13 additions & 1 deletion plugins/outputs/remotefile/remotefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"text/template"
"time"

"github.com/dustin/go-humanize"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/fspath"
"github.com/rclone/rclone/vfs"
Expand Down Expand Up @@ -126,9 +127,20 @@ func (f *File) Connect() error {
return fmt.Errorf("creating remote failed: %w", err)
}
f.fscancel = cancel

f.root = vfs.New(rootfs, &f.vfsopts)

// Force connection to make sure we actually can connect
if _, err := f.root.Fs().List(ctx, "/"); err != nil {
return err
}
total, used, free := f.root.Statfs()
f.Log.Debugf("Connected to %s with %s total, %s used and %s free!",
f.root.Fs().String(),
humanize.Bytes(uint64(total)),
humanize.Bytes(uint64(used)),
humanize.Bytes(uint64(free)),
)

return nil
}

Expand Down

0 comments on commit 7a753b4

Please sign in to comment.