Name the remote and rclone config file in rclone setup errors (closes #467)
check / check (push) Waiting to run

A remote missing from the config and a remote that fails to open now
both name the remote and the rclone config file vaultik read, and say
when that file does not exist.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-19 07:30:57 +00:00
1 parent d747ddef3a
commit cd86db7416
2 files changed
+103 -9

No files matched your search

+20 -2
View File
@@ -67,10 +67,12 @@ func NewRcloneStorer(ctx context.Context, remote, path string) (*RcloneStorer, e
// Check for remote not found error
if strings.Contains(err.Error(), "didn't find section in config file") ||
strings.Contains(err.Error(), "failed to find remote") {
return nil, fmt.Errorf("%w: %s", ErrRemoteNotFound, remote)
return nil, fmt.Errorf("%w: %q (%s)",
ErrRemoteNotFound, remote, describeRcloneConfigFile())
}
return nil, fmt.Errorf("creating rclone filesystem: %w", err)
return nil, fmt.Errorf("opening rclone remote %q (%s): %w",
remote, describeRcloneConfigFile(), err)
}
return &RcloneStorer{
@@ -324,6 +326,22 @@ func (r *RcloneStorer) upload(ctx context.Context, key string, data io.Reader) e
return nil
}
// describeRcloneConfigFile names the rclone config file for an error
// message, and says so when that file does not exist.
func describeRcloneConfigFile() string {
path := config.GetConfigPath()
if path == "" {
return "no config file"
}
_, err := os.Stat(path)
if errors.Is(err, os.ErrNotExist) {
return fmt.Sprintf("config file %q, which does not exist", path)
}
return fmt.Sprintf("config file %q", path)
}
// progressReader wraps an io.Reader to track read progress.
type progressReader struct {
reader io.Reader