(ctx context.Context, srcurl, dsturl *url.URL, extradata map[string]string)
| 782 | } |
| 783 | |
| 784 | func (c Copy) doCopy(ctx context.Context, srcurl, dsturl *url.URL, extradata map[string]string) error { |
| 785 | // override destination region if set |
| 786 | if c.dstRegion != "" { |
| 787 | c.storageOpts.SetRegion(c.dstRegion) |
| 788 | } |
| 789 | dstClient, err := storage.NewClient(ctx, dsturl, c.storageOpts) |
| 790 | if err != nil { |
| 791 | return err |
| 792 | } |
| 793 | |
| 794 | metadata := storage.Metadata{ |
| 795 | UserDefined: extradata, |
| 796 | ACL: c.acl, |
| 797 | CacheControl: c.cacheControl, |
| 798 | Expires: c.expires, |
| 799 | StorageClass: string(c.storageClass), |
| 800 | ContentType: c.contentType, |
| 801 | ContentEncoding: c.contentEncoding, |
| 802 | ContentDisposition: c.contentDisposition, |
| 803 | EncryptionMethod: c.encryptionMethod, |
| 804 | EncryptionKeyID: c.encryptionKeyID, |
| 805 | Directive: c.metadataDirective, |
| 806 | } |
| 807 | |
| 808 | err = c.shouldOverride(ctx, srcurl, dsturl) |
| 809 | if err != nil { |
| 810 | if errorpkg.IsWarning(err) { |
| 811 | printDebug(c.op, err, srcurl, dsturl) |
| 812 | return nil |
| 813 | } |
| 814 | return err |
| 815 | } |
| 816 | |
| 817 | err = dstClient.Copy(ctx, srcurl, dsturl, metadata) |
| 818 | if err != nil { |
| 819 | return err |
| 820 | } |
| 821 | |
| 822 | if c.deleteSource { |
| 823 | srcClient, err := storage.NewClient(ctx, srcurl, c.storageOpts) |
| 824 | if err != nil { |
| 825 | return err |
| 826 | } |
| 827 | if err := srcClient.Delete(ctx, srcurl); err != nil { |
| 828 | return err |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | msg := log.InfoMessage{ |
| 833 | Operation: c.op, |
| 834 | Source: srcurl, |
| 835 | Destination: dsturl, |
| 836 | Object: &storage.Object{ |
| 837 | URL: dsturl, |
| 838 | StorageClass: c.storageClass, |
| 839 | }, |
| 840 | } |
| 841 | log.Info(msg) |
no test coverage detected