MCPcopy
hub / github.com/rclone/rclone / predictDstFromLogger

Function predictDstFromLogger

fs/sync/sync_test.go:2985–3018  ·  view source on GitHub ↗

for testing logger:

(ctx context.Context)

Source from the content-addressed store, hash-verified

2983
2984// for testing logger:
2985func predictDstFromLogger(ctx context.Context) context.Context {
2986 opt := operations.NewLoggerOpt()
2987 var lock mutex.Mutex
2988
2989 opt.LoggerFn = func(ctx context.Context, sigil operations.Sigil, src, dst fs.DirEntry, err error) {
2990 lock.Lock()
2991 defer lock.Unlock()
2992
2993 // ignore dirs for our purposes here
2994 if err == fs.ErrorIsDir {
2995 return
2996 }
2997 winner := operations.WinningSide(ctx, sigil, src, dst, err)
2998 if winner.Obj != nil {
2999 file := winner.Obj
3000 obj, ok := file.(fs.ObjectInfo)
3001 checksum := ""
3002 timeFormat := "2006-01-02 15:04:05"
3003 if ok {
3004 if obj.Fs().Hashes().GetOne() == hash.MD5 {
3005 // skip if no MD5
3006 checksum, _ = obj.Hash(ctx, hash.MD5)
3007 }
3008 timeFormat = operations.FormatForLSFPrecision(obj.Fs().Precision())
3009 }
3010 errMsg := ""
3011 if winner.Err != nil {
3012 errMsg = ";" + winner.Err.Error()
3013 }
3014 operations.SyncFprintf(opt.JSON, "%s;%s;%v;%s%s\n", file.ModTime(ctx).Local().Format(timeFormat), checksum, file.Size(), transform.Path(ctx, file.Remote(), false), errMsg) // TODO: should the transform be handled in the sync instead of here?
3015 }
3016 }
3017 return operations.WithSyncLogger(ctx, opt)
3018}
3019
3020func DstLsf(ctx context.Context, Fremote fs.Fs) *bytes.Buffer {
3021 opt := operations.ListJSONOpt{

Callers 15

TestTransformCopyFunction · 0.85
TestDoubleTransformFunction · 0.85
TestFileTagFunction · 0.85
TestNoTagFunction · 0.85
TestDirTagFunction · 0.85
TestAllTagFunction · 0.85
TestRunTwiceFunction · 0.85
TestConflictingFunction · 0.85
TestMoveFunction · 0.85
TestTransformFileFunction · 0.85
TestManualTransformFileFunction · 0.85
TestBase64Function · 0.85

Calls 15

NewLoggerOptFunction · 0.92
WinningSideFunction · 0.92
FormatForLSFPrecisionFunction · 0.92
SyncFprintfFunction · 0.92
PathFunction · 0.92
WithSyncLoggerFunction · 0.92
GetOneMethod · 0.80
FormatMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
HashesMethod · 0.65
FsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…