MCPcopy
hub / github.com/rclone/rclone / getModTime

Method getModTime

backend/b2/b2.go:2317–2343  ·  view source on GitHub ↗

Get modTime from the source; if --metadata is set, fetch the src metadata and get it from there. When metadata support is added to b2, this method will need a more generic name

(ctx context.Context, src fs.ObjectInfo, options []fs.OpenOption)

Source from the content-addressed store, hash-verified

2315// Get modTime from the source; if --metadata is set, fetch the src metadata and get it from there.
2316// When metadata support is added to b2, this method will need a more generic name
2317func (o *Object) getModTime(ctx context.Context, src fs.ObjectInfo, options []fs.OpenOption) (time.Time, error) {
2318 modTime := src.ModTime(ctx)
2319
2320 // Fetch metadata if --metadata is in use
2321 meta, err := fs.GetMetadataOptions(ctx, o.fs, src, options)
2322 if err != nil {
2323 return time.Time{}, fmt.Errorf("failed to read metadata from source object: %w", err)
2324 }
2325 // merge metadata into request and user metadata
2326 for k, v := range meta {
2327 k = strings.ToLower(k)
2328 // For now, the only metadata we're concerned with is "mtime"
2329 switch k {
2330 case "mtime":
2331 // mtime in meta overrides source ModTime
2332 metaModTime, err := time.Parse(time.RFC3339Nano, v)
2333 if err != nil {
2334 fs.Debugf(o, "failed to parse metadata %s: %q: %v", k, v, err)
2335 } else {
2336 modTime = metaModTime
2337 }
2338 default:
2339 // Do nothing for now
2340 }
2341 }
2342 return modTime, nil
2343}
2344
2345// OpenChunkWriter returns the chunk size and a ChunkWriter
2346//

Callers 2

UpdateMethod · 0.95
newLargeUploadMethod · 0.80

Calls 4

GetMetadataOptionsFunction · 0.92
DebugfFunction · 0.92
ModTimeMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected