@@ -189,20 +189,6 @@ type rawCopyCmdArgs struct {
189
189
deleteDestinationFileIfNecessary bool
190
190
}
191
191
192
- func (raw * rawCopyCmdArgs ) parsePatterns (pattern string ) (cookedPatterns []string ) {
193
- cookedPatterns = make ([]string , 0 )
194
- rawPatterns := strings .Split (pattern , ";" )
195
- for _ , pattern := range rawPatterns {
196
-
197
- // skip the empty patterns
198
- if len (pattern ) != 0 {
199
- cookedPatterns = append (cookedPatterns , pattern )
200
- }
201
- }
202
-
203
- return
204
- }
205
-
206
192
// blocSizeInBytes converts a FLOATING POINT number of MiB, to a number of bytes
207
193
// A non-nil error is returned if the conversion is not possible to do accurately (e.g. it comes out of a fractional number of bytes)
208
194
// The purpose of using floating point is to allow specialist users (e.g. those who want small block sizes to tune their read IOPS)
@@ -226,47 +212,6 @@ func blockSizeInBytes(rawBlockSizeInMiB float64) (int64, error) {
226
212
return int64 (math .Round (rawSizeInBytes )), nil
227
213
}
228
214
229
- // returns result of stripping and if striptopdir is enabled
230
- // if nothing happens, the original source is returned
231
- func (raw rawCopyCmdArgs ) stripTrailingWildcardOnRemoteSource (location common.Location ) (result string , stripTopDir bool , err error ) {
232
- result = raw .src
233
- resourceURL , err := url .Parse (result )
234
- gURLParts := common .NewGenericResourceURLParts (* resourceURL , location )
235
-
236
- if err != nil {
237
- err = fmt .Errorf ("failed to parse url %s; %w" , result , err )
238
- return
239
- }
240
-
241
- if strings .Contains (gURLParts .GetContainerName (), "*" ) {
242
- // Disallow container name search and object specifics
243
- if gURLParts .GetObjectName () != "" {
244
- err = errors .New ("cannot combine a specific object name with an account-level search" )
245
- return
246
- }
247
-
248
- // Return immediately here because we know this will be safe.
249
- return
250
- }
251
-
252
- // Trim the trailing /*.
253
- if strings .HasSuffix (resourceURL .RawPath , "/*" ) {
254
- resourceURL .RawPath = strings .TrimSuffix (resourceURL .RawPath , "/*" )
255
- resourceURL .Path = strings .TrimSuffix (resourceURL .Path , "/*" )
256
- stripTopDir = true
257
- }
258
-
259
- // Ensure there aren't any extra *s floating around.
260
- if strings .Contains (resourceURL .RawPath , "*" ) {
261
- err = errors .New ("cannot use wildcards in the path section of the URL except in trailing \" /*\" . If you wish to use * in your URL, manually encode it to %2A" )
262
- return
263
- }
264
-
265
- result = resourceURL .String ()
266
-
267
- return
268
- }
269
-
270
215
func (raw rawCopyCmdArgs ) cook () (CookedCopyCmdArgs , error ) {
271
216
cooked := CookedCopyCmdArgs {
272
217
jobID : azcopyCurrentJobID ,
@@ -298,7 +243,7 @@ func (raw rawCopyCmdArgs) cook() (CookedCopyCmdArgs, error) {
298
243
299
244
// Check if source has a trailing wildcard on a URL
300
245
if fromTo .From ().IsRemote () {
301
- tempSrc , cooked .StripTopDir , err = raw . stripTrailingWildcardOnRemoteSource (fromTo .From ())
246
+ tempSrc , cooked .StripTopDir , err = stripTrailingWildcardOnRemoteSource (raw . src , fromTo .From ())
302
247
303
248
if err != nil {
304
249
return cooked , err
@@ -410,7 +355,7 @@ func (raw rawCopyCmdArgs) cook() (CookedCopyCmdArgs, error) {
410
355
}
411
356
412
357
// warn on exclude unsupported wildcards here. Include have to be later, to cover list-of-files
413
- raw . warnIfHasWildcard (excludeWarningOncer , "exclude-path" , raw .excludePath )
358
+ warnIfHasWildcard (excludeWarningOncer , "exclude-path" , raw .excludePath )
414
359
415
360
// unbuffered so this reads as we need it to rather than all at once in bulk
416
361
listChan := make (chan string )
@@ -433,7 +378,7 @@ func (raw rawCopyCmdArgs) cook() (CookedCopyCmdArgs, error) {
433
378
addToChannel := func (v string , paramName string ) {
434
379
// empty strings should be ignored, otherwise the source root itself is selected
435
380
if len (v ) > 0 {
436
- raw . warnIfHasWildcard (includeWarningOncer , paramName , v )
381
+ warnIfHasWildcard (includeWarningOncer , paramName , v )
437
382
listChan <- v
438
383
}
439
384
}
@@ -477,7 +422,7 @@ func (raw rawCopyCmdArgs) cook() (CookedCopyCmdArgs, error) {
477
422
}
478
423
479
424
// This occurs much earlier than the other include or exclude filters. It would be preferable to move them closer later on in the refactor.
480
- includePathList := raw . parsePatterns (raw .includePath )
425
+ includePathList := parsePatterns (raw .includePath )
481
426
482
427
for _ , v := range includePathList {
483
428
addToChannel (v , "include-path" )
@@ -868,19 +813,19 @@ func (raw rawCopyCmdArgs) cook() (CookedCopyCmdArgs, error) {
868
813
}
869
814
870
815
// parse the filter patterns
871
- cooked .IncludePatterns = raw . parsePatterns (raw .include )
872
- cooked .ExcludePatterns = raw . parsePatterns (raw .exclude )
873
- cooked .ExcludePathPatterns = raw . parsePatterns (raw .excludePath )
874
- cooked .excludeContainer = raw . parsePatterns (raw .excludeContainer )
816
+ cooked .IncludePatterns = parsePatterns (raw .include )
817
+ cooked .ExcludePatterns = parsePatterns (raw .exclude )
818
+ cooked .ExcludePathPatterns = parsePatterns (raw .excludePath )
819
+ cooked .excludeContainer = parsePatterns (raw .excludeContainer )
875
820
876
821
if (raw .includeFileAttributes != "" || raw .excludeFileAttributes != "" ) && fromTo .From () != common .ELocation .Local () {
877
822
return cooked , errors .New ("cannot check file attributes on remote objects" )
878
823
}
879
- cooked .IncludeFileAttributes = raw . parsePatterns (raw .includeFileAttributes )
880
- cooked .ExcludeFileAttributes = raw . parsePatterns (raw .excludeFileAttributes )
824
+ cooked .IncludeFileAttributes = parsePatterns (raw .includeFileAttributes )
825
+ cooked .ExcludeFileAttributes = parsePatterns (raw .excludeFileAttributes )
881
826
882
- cooked .includeRegex = raw . parsePatterns (raw .includeRegex )
883
- cooked .excludeRegex = raw . parsePatterns (raw .excludeRegex )
827
+ cooked .includeRegex = parsePatterns (raw .includeRegex )
828
+ cooked .excludeRegex = parsePatterns (raw .excludeRegex )
884
829
885
830
cooked .dryrunMode = raw .dryrun
886
831
@@ -903,16 +848,6 @@ func (raw rawCopyCmdArgs) cook() (CookedCopyCmdArgs, error) {
903
848
var excludeWarningOncer = & sync.Once {}
904
849
var includeWarningOncer = & sync.Once {}
905
850
906
- func (raw * rawCopyCmdArgs ) warnIfHasWildcard (oncer * sync.Once , paramName string , value string ) {
907
- if strings .Contains (value , "*" ) || strings .Contains (value , "?" ) {
908
- oncer .Do (func () {
909
- glcm .Warn (fmt .Sprintf ("*** Warning *** The %s parameter does not support wildcards. The wildcard " +
910
- "character provided will be interpreted literally and will not have any wildcard effect. To use wildcards " +
911
- "(in filenames only, not paths) use include-pattern or exclude-pattern" , paramName ))
912
- })
913
- }
914
- }
915
-
916
851
// When other commands use the copy command arguments to cook cook, set the blobType to None and validation option
917
852
// else parsing the arguments will fail.
918
853
func (raw * rawCopyCmdArgs ) setMandatoryDefaults () {
0 commit comments