MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / determineTransferDirection

Function determineTransferDirection

cmd/scp.go:185–212  ·  view source on GitHub ↗
(sources []PathInfo, dest PathInfo)

Source from the content-addressed store, hash-verified

183}
184
185func determineTransferDirection(sources []PathInfo, dest PathInfo) (string, string, error) {
186 remoteCount := 0
187 var remoteInstanceID string
188
189 for _, src := range sources {
190 if src.IsRemote {
191 remoteCount++
192 if remoteInstanceID == "" {
193 remoteInstanceID = src.InstanceID
194 } else if remoteInstanceID != src.InstanceID {
195 return "", "", usageErr("cannot transfer between multiple instances")
196 }
197 }
198 }
199
200 if dest.IsRemote {
201 if remoteCount > 0 {
202 return "", "", usageErr("cannot transfer from remote to remote")
203 }
204 return "upload", dest.InstanceID, nil
205 }
206
207 if remoteCount == 0 {
208 return "", "", usageErr("no remote path specified (use instance_id:/path)")
209 }
210
211 return "download", remoteInstanceID, nil
212}

Callers 3

runSCPFunction · 0.85

Calls 1

usageErrFunction · 0.85