RenameFile renames (moves) file.
(oldName, newName string)
| 339 | |
| 340 | // RenameFile renames (moves) file. |
| 341 | func (g *PublishedStorage) RenameFile(oldName, newName string) error { |
| 342 | src := g.objectHandle(oldName) |
| 343 | dst := g.objectHandle(newName) |
| 344 | |
| 345 | if g.debug { |
| 346 | log.Debug().Msgf("GCS: RenameFile %s -> %s", oldName, newName) |
| 347 | } |
| 348 | |
| 349 | _, err := dst.CopierFrom(src).Run(context.TODO()) |
| 350 | if err != nil { |
| 351 | return fmt.Errorf("error copying %s -> %s in %s: %s", oldName, newName, g, err) |
| 352 | } |
| 353 | |
| 354 | err = g.applyACL(dst) |
| 355 | if err != nil { |
| 356 | return err |
| 357 | } |
| 358 | |
| 359 | return g.Remove(oldName) |
| 360 | } |
| 361 | |
| 362 | // SymLink creates a copy of src file and stores link information in metadata. |
| 363 | func (g *PublishedStorage) SymLink(src string, dst string) error { |