for testing logger:
(ctx context.Context)
| 2983 | |
| 2984 | // for testing logger: |
| 2985 | func 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 | |
| 3020 | func DstLsf(ctx context.Context, Fremote fs.Fs) *bytes.Buffer { |
| 3021 | opt := operations.ListJSONOpt{ |
no test coverage detected
searching dependent graphs…