Skip to content

rclone misc#37

Open
omar-polo wants to merge 9 commits into
integration/rclonefrom
op/rclone-misc
Open

rclone misc#37
omar-polo wants to merge 9 commits into
integration/rclonefrom
op/rclone-misc

Conversation

@omar-polo

Copy link
Copy Markdown
Collaborator

No description provided.

scanFolder does not use the path.  It's ListFolder that request a
specific path, scanFolder only consumes the reply.
it's a TOCTOU not needed.  we already have in the stdlib CreateTemp()
which deals with concurrency.
Otherwise we might leave records unprocessed on the channel.  It'll
be the responsability of the caller to close records on cancellation.
The functions run with Go() won't fail, and we don't need ctx.Done()
to close on Wait().
@omar-polo

Copy link
Copy Markdown
Collaborator Author

better read commit by commit, and in one case even with the white spaces disabled. all commits (should be?) are trivial, no functional changes intended.

@omar-polo

Copy link
Copy Markdown
Collaborator Author

extra note: I don't know why AutoremoveTmpFile in its Close() has the temp file removal commented.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes a set of small cleanups across the rclone integration, primarily around RPC payload typing, importer temp-file handling, and exporter concurrency/control-flow.

Changes:

  • Tighten rclone RPC payload types from map[string]interface{} to map[string]string.
  • Simplify importer scanning by removing unused path-component helpers and adjusting scanFolder call sites.
  • Refactor exporter Export loop/concurrency wiring.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
rclone/storage/storage.go Uses a map[string]string payload for operations/list.
rclone/importer/importer.go Removes debug-only artifacts, simplifies scanning, adjusts list/copy payload typing, and changes temp file creation logic for downloads.
rclone/exporter/exporter.go Refactors Export to a simpler range loop with an errgroup.Group concurrency limit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 128 to +130
func (p *RcloneImporter) scanRecursive(results chan<- *connectors.Record, path string, wg *sync.WaitGroup) {
response, _ := p.ListFolder(results, path)
p.scanFolder(results, path, response, wg)
p.scanFolder(results, response, wg)
Comment on lines 133 to 137
func (p *RcloneImporter) ListFolder(results chan<- *connectors.Record, path string) (Response, error) {
payload := map[string]interface{}{
payload := map[string]string{
"fs": fmt.Sprintf("%s:%s", p.Typee, p.Base),
"remote": path,
}
Comment on lines 258 to 262
return nil, fmt.Errorf("failed to copy file: %s", body)
}

tmpFile, err := os.Open(name)
if err != nil {
return nil, err
}

return &AutoremoveTmpFile{tmpFile}, nil
return &AutoremoveTmpFile{fp}, nil
}
Comment on lines +90 to +94
for record := range records {
if record.Err != nil {
results <- record.Ok()
continue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants