MCPcopy Index your code
hub / github.com/peak/s5cmd / doCopy

Method doCopy

command/cp.go:784–844  ·  view source on GitHub ↗
(ctx context.Context, srcurl, dsturl *url.URL, extradata map[string]string)

Source from the content-addressed store, hash-verified

782}
783
784func (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)

Callers 1

prepareCopyTaskMethod · 0.95

Calls 7

shouldOverrideMethod · 0.95
NewClientFunction · 0.92
InfoFunction · 0.92
printDebugFunction · 0.85
SetRegionMethod · 0.80
CopyMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected