@@ -69,6 +69,7 @@ type copyOptionType struct {
69
69
type filterOptionType struct {
70
70
name string
71
71
pattern string
72
+ isDir bool
72
73
}
73
74
74
75
type fileInfoType struct {
@@ -210,7 +211,6 @@ var specChineseCopy = SpecText{
210
211
?:匹配单个字符
211
212
[sequence]:匹配sequence的任意字符
212
213
[!sequence]:匹配不在sequence的任意字符
213
- 注意:规则不支持带目录的格式,e.g.,--include "/usr/*/test/*.jpg"。
214
214
215
215
--include和--exclude可以出现多次。当多个规则出现时,这些规则按从左往右的顺序应用。例如:
216
216
当前目录下包含3个文件:
@@ -229,6 +229,23 @@ var specChineseCopy = SpecText{
229
229
$ ossutil cp . oss://my-bucket/path --exclude '*.jpg' --include 'testfile*.jpg' --exclude 'testfile?.jpg'
230
230
上传testfile2.txt到oss://my-bucket/path/testfile2.txt
231
231
上传testfile33.jpg到oss://my-bucket/path/testfile33.jpg
232
+
233
+ 当前目录下包含3个文件一个目录:
234
+ testfile1.jpg
235
+ testfiel2.txt
236
+ testfile33.jpg
237
+ testdir1
238
+ -testfile1.txt
239
+ -testfile2.txt
240
+ -testfile3.txt
241
+ $ ossutil cp . oss://my-bucket/path --include 'testdir1/*'
242
+ 上传testdir1目录下的文件到oss://my-bucket/path/testdir1/
243
+
244
+ $ ossutil cp . oss://my-bucket/path --exclude 'testdir1/*'
245
+ 上传testfile1.jpg到oss://my-bucket/path/testfile1.jpg
246
+ 上传testfile2.txt到oss://my-bucket/path/testfile2.txt
247
+ 上传testfile33.jpg到oss://my-bucket/path/testfile33.jpg
248
+
232
249
233
250
--meta选项
234
251
@@ -736,7 +753,6 @@ var specEnglishCopy = SpecText{
736
753
?: Matches any single character
737
754
[sequence]: Matches any character in sequence
738
755
[!sequence]: Matches any character not in sequence
739
- Note: does not support patterns containing directory info. e.g., --include "/usr/*/test/*.jpg"
740
756
741
757
Any number of these parameters can be passed to a command. You can do this by providing an --exclude
742
758
or --include argument multiple times, e.g.,
@@ -767,6 +783,22 @@ var specEnglishCopy = SpecText{
767
783
upload testfile2.txt to oss://my-bucket/path/testfile2.txt
768
784
upload testfile33.jpg to oss://my-bucket/path/testfile33.jpg
769
785
786
+ e.g., 3 files in current dir and 1 subdir
787
+ testfile1.jpg
788
+ testfiel2.txt
789
+ testfile33.jpg
790
+ testdir1
791
+ -testfile1.txt
792
+ -testfile2.txt
793
+ -testfile3.txt
794
+ $ ossutil cp . oss://my-bucket/path --include 'testdir1/*'
795
+ upload files in testdir1 directory to oss://my-bucket/path/testdir1/
796
+
797
+ $ ossutil cp . oss://my-bucket/path --exclude 'testdir1/*'
798
+ upload testfile1.jpg to oss://my-bucket/path/testfile1.jpg
799
+ upload testfile2.txt to oss://my-bucket/path/testfile2.txt
800
+ upload testfile33.jpg to oss://my-bucket/path/testfile33.jpg
801
+
770
802
--meta option
771
803
772
804
This option will set the specified objects' meta data. If --recursive option is specified,
@@ -1769,7 +1801,10 @@ func (cc *CopyCommand) getFileListStatistic(dpath string) error {
1769
1801
1770
1802
if f .IsDir () {
1771
1803
if fpath != dpath {
1772
- cc .monitor .updateScanNum (1 )
1804
+ if doesSingleFileMatchPatterns (fpath , cc .cpOption .filters ) {
1805
+ cc .monitor .updateScanNum (1 )
1806
+ }
1807
+
1773
1808
}
1774
1809
return nil
1775
1810
}
@@ -1803,7 +1838,7 @@ func (cc *CopyCommand) getFileListStatistic(dpath string) error {
1803
1838
return nil
1804
1839
}
1805
1840
}
1806
- if doesSingleFileMatchPatterns (f . Name () , cc .cpOption .filters ) {
1841
+ if doesSingleFileMatchPatterns (fpath , cc .cpOption .filters ) {
1807
1842
cc .monitor .updateScanSizeNum (realFileSize , 1 )
1808
1843
}
1809
1844
return nil
@@ -1903,11 +1938,14 @@ func (cc *CopyCommand) getFileList(dpath string, chFiles chan<- fileInfoType) er
1903
1938
1904
1939
if f .IsDir () {
1905
1940
if fpath != dpath {
1906
- if strings .HasSuffix (fileName , "\\ " ) || strings .HasSuffix (fileName , "/" ) {
1907
- chFiles <- fileInfoType {fileName , name }
1908
- } else {
1909
- chFiles <- fileInfoType {fileName + string (os .PathSeparator ), name }
1941
+ if doesSingleFileMatchPatterns (fpath , cc .cpOption .filters ) {
1942
+ if strings .HasSuffix (fileName , "\\ " ) || strings .HasSuffix (fileName , "/" ) {
1943
+ chFiles <- fileInfoType {fileName , name }
1944
+ } else {
1945
+ chFiles <- fileInfoType {fileName + string (os .PathSeparator ), name }
1946
+ }
1910
1947
}
1948
+
1911
1949
}
1912
1950
return nil
1913
1951
}
@@ -1934,8 +1972,7 @@ func (cc *CopyCommand) getFileList(dpath string, chFiles chan<- fileInfoType) er
1934
1972
return nil
1935
1973
}
1936
1974
}
1937
-
1938
- if doesSingleFileMatchPatterns (fileName , cc .cpOption .filters ) {
1975
+ if doesSingleFileMatchPatterns (fpath , cc .cpOption .filters ) {
1939
1976
chFiles <- fileInfoType {fileName , name }
1940
1977
}
1941
1978
return nil
@@ -2369,7 +2406,6 @@ func (cc *CopyCommand) downloadFiles(srcURL CloudURL, destURL FileURL) error {
2369
2406
prefix = srcURL .object [:index + 1 ]
2370
2407
relativeKey = srcURL .object [index + 1 :]
2371
2408
}
2372
-
2373
2409
go cc .objectStatistic (bucket , srcURL )
2374
2410
err := cc .downloadSingleFileWithReport (bucket , objectInfoType {prefix , relativeKey , - 1 , time .Now ()}, filePath )
2375
2411
return cc .formatResultPrompt (err )
0 commit comments