MCPcopy
hub / github.com/rclone/rclone / completeAllBackgroundUploads

Method completeAllBackgroundUploads

backend/cache/cache_internal_test.go:1261–1292  ·  view source on GitHub ↗
(t *testing.T, f fs.Fs, lastRemote string)

Source from the content-addressed store, hash-verified

1259}
1260
1261func (r *run) completeAllBackgroundUploads(t *testing.T, f fs.Fs, lastRemote string) {
1262 var state cache.BackgroundUploadState
1263 var err error
1264
1265 maxDuration := time.Minute * 5
1266 if r.wrappedIsExternal {
1267 maxDuration = time.Minute * 15
1268 }
1269 cfs, err := r.getCacheFs(f)
1270 require.NoError(t, err)
1271 buCh := cfs.GetBackgroundUploadChannel()
1272 require.NotNil(t, buCh)
1273
1274 for {
1275 select {
1276 case state = <-buCh:
1277 checkRemote := state.Remote
1278 if r.rootIsCrypt {
1279 cryptFs := f.(*crypt.Fs)
1280 checkRemote, err = cryptFs.DecryptFileName(checkRemote)
1281 require.NoError(t, err)
1282 }
1283 if checkRemote == lastRemote && cache.BackgroundUploadCompleted == state.Status {
1284 require.NoError(t, state.Error)
1285 return
1286 }
1287 case <-time.After(maxDuration):
1288 t.Fatalf("Timed out waiting to complete the background upload %v", lastRemote)
1289 return
1290 }
1291 }
1292}
1293
1294func (r *run) retryBlock(block func() error, maxRetries int, rate time.Duration) error {
1295 var err error

Calls 4

getCacheFsMethod · 0.95
FatalfMethod · 0.80
DecryptFileNameMethod · 0.45

Tested by

no test coverage detected