SetModTime sets the modification time of the local fs object
(ctx context.Context, modTime time.Time)
| 1342 | |
| 1343 | // SetModTime sets the modification time of the local fs object |
| 1344 | func (o *Object) SetModTime(ctx context.Context, modTime time.Time) (err error) { |
| 1345 | // read the complete existing object first |
| 1346 | object, err := o.readObjectInfo(ctx) |
| 1347 | if err != nil { |
| 1348 | return err |
| 1349 | } |
| 1350 | // Add the mtime to the existing metadata |
| 1351 | if object.Metadata == nil { |
| 1352 | object.Metadata = make(map[string]string, 1) |
| 1353 | } |
| 1354 | object.Metadata[metaMtime] = modTime.Format(timeFormat) |
| 1355 | object.Metadata[metaMtimeGsutil] = strconv.FormatInt(modTime.Unix(), 10) |
| 1356 | // Copy the object to itself to update the metadata |
| 1357 | // Using PATCH requires too many permissions |
| 1358 | bucket, bucketPath := o.split() |
| 1359 | var newObject *storage.Object |
| 1360 | err = o.fs.pacer.Call(func() (bool, error) { |
| 1361 | copyObject := o.fs.svc.Objects.Copy(bucket, bucketPath, bucket, bucketPath, object) |
| 1362 | if !o.fs.opt.BucketPolicyOnly { |
| 1363 | copyObject.DestinationPredefinedAcl(o.fs.opt.ObjectACL) |
| 1364 | } |
| 1365 | copyObject = copyObject.Context(ctx) |
| 1366 | if o.fs.opt.UserProject != "" { |
| 1367 | copyObject = copyObject.UserProject(o.fs.opt.UserProject) |
| 1368 | } |
| 1369 | newObject, err = copyObject.Do() |
| 1370 | return shouldRetry(ctx, err) |
| 1371 | }) |
| 1372 | if err != nil { |
| 1373 | return err |
| 1374 | } |
| 1375 | o.setMetaData(newObject) |
| 1376 | return nil |
| 1377 | } |
| 1378 | |
| 1379 | // Storable returns a boolean as to whether this object is storable |
| 1380 | func (o *Object) Storable() bool { |
nothing calls this directly
no test coverage detected