MCPcopy
hub / github.com/rclone/rclone / restore

Method restore

backend/oracleobjectstorage/command.go:352–410  ·  view source on GitHub ↗
(ctx context.Context, opt map[string]string)

Source from the content-addressed store, hash-verified

350}
351
352func (f *Fs) restore(ctx context.Context, opt map[string]string) (any, error) {
353 req := objectstorage.RestoreObjectsRequest{
354 NamespaceName: common.String(f.opt.Namespace),
355 RestoreObjectsDetails: objectstorage.RestoreObjectsDetails{},
356 }
357 if hours := opt["hours"]; hours != "" {
358 ihours, err := strconv.Atoi(hours)
359 if err != nil {
360 return nil, fmt.Errorf("bad value for hours: %w", err)
361 }
362 req.RestoreObjectsDetails.Hours = &ihours
363 }
364 type status struct {
365 Object string
366 Status string
367 }
368 var (
369 outMu sync.Mutex
370 out = []status{}
371 err error
372 )
373 err = operations.ListFn(ctx, f, func(obj fs.Object) {
374 // Remember this is run --checkers times concurrently
375 o, ok := obj.(*Object)
376 st := status{Object: obj.Remote(), Status: "RESTORED"}
377 defer func() {
378 outMu.Lock()
379 out = append(out, st)
380 outMu.Unlock()
381 }()
382 if !ok {
383 st.Status = "Not an OCI Object Storage object"
384 return
385 }
386 if o.storageTier == nil || (*o.storageTier != "archive") {
387 st.Status = "Object not in Archive storage tier"
388 return
389 }
390 if operations.SkipDestructive(ctx, obj, "restore") {
391 return
392 }
393 bucket, bucketPath := o.split()
394 reqCopy := req
395 reqCopy.BucketName = &bucket
396 reqCopy.ObjectName = &bucketPath
397 var response objectstorage.RestoreObjectsResponse
398 err = f.pacer.Call(func() (bool, error) {
399 response, err = f.srv.RestoreObjects(ctx, reqCopy)
400 return shouldRetry(ctx, response.HTTPResponse(), err)
401 })
402 if err != nil {
403 st.Status = err.Error()
404 }
405 })
406 if err != nil {
407 return out, err
408 }
409 return out, nil

Callers 1

CommandMethod · 0.95

Calls 11

ListFnFunction · 0.92
SkipDestructiveFunction · 0.92
shouldRetryFunction · 0.70
StringMethod · 0.65
RemoteMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.45
splitMethod · 0.45
CallMethod · 0.45

Tested by

no test coverage detected