@@ -64,6 +64,8 @@ type copyOptionType struct {
64
64
tagging string
65
65
opType operationType
66
66
bSyncCommand bool
67
+ startTime int64
68
+ endTime int64
67
69
}
68
70
69
71
type filterOptionType struct {
@@ -350,6 +352,13 @@ var specChineseCopy = SpecText{
350
352
和-r选项一起使用,表示只操作当前目录下的文件, 会忽略当前目录下的子目录, 如果是下载或者拷贝oss
351
353
的目录,目录后面要加上反斜线/
352
354
355
+ --start-time
356
+ 时间戳, 既从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数
357
+ 如果输入这个选项, 文件的最后修改时间小于该时间戳将被忽略
358
+
359
+ --end-time
360
+ 时间戳, 既从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数
361
+ 如果输入这个选项, 文件的最后修改时间大于该时间戳将被忽略
353
362
354
363
大文件断点续传:
355
364
@@ -893,20 +902,30 @@ Other Options:
893
902
894
903
--enable-symlink-dir option
895
904
896
- Allows transfer of files in the link subdirectory. If there is an infinite loop link file or directory,
897
- it will cause an error.
898
- It is recommended to use the probe command to detect the existence of an infinite loop link file or
899
- directory before use
905
+ Allows transfer of files in the link subdirectory. If there is an infinite loop link file or directory,
906
+ it will cause an error.
907
+ It is recommended to use the probe command to detect the existence of an infinite loop link file or
908
+ directory before use
900
909
901
910
--disable-all-symlink option
902
911
903
- specifies that uploading of symlink files and symlink directories under the directory is not allowed
912
+ specifies that uploading of symlink files and symlink directories under the directory is not allowed
904
913
905
914
--only-current-dir
906
915
907
- Used with the -r option, it means that only the files in the current directory will be manipulated,
908
- and the subdirectories under the current directory will be ignored.
909
- If you are downloading or copying the oss directory, add a backslash(/) after the directory.
916
+ Used with the -r option, it means that only the files in the current directory will be manipulated,
917
+ and the subdirectories under the current directory will be ignored.
918
+ If you are downloading or copying the oss directory, add a backslash(/) after the directory.
919
+
920
+ --start-time
921
+
922
+ Timestamp, the number of seconds that elapsed from January 1, 1970 (midnight UTC/GMT).
923
+ If this option is set, do not transfer files that have last modified time less than this.
924
+
925
+ --end-time
926
+
927
+ Timestamp, the number of seconds that elapsed from January 1, 1970 (midnight UTC/GMT).
928
+ If this option is set, do not transfer files that have last modified time greater than this.
910
929
911
930
Resume copy of big file:
912
931
@@ -1295,6 +1314,8 @@ var copyCommand = CopyCommand{
1295
1314
OptionRegion ,
1296
1315
OptionCloudBoxID ,
1297
1316
OptionForcePathStyle ,
1317
+ OptionStartTime ,
1318
+ OptionEndTime ,
1298
1319
},
1299
1320
},
1300
1321
}
@@ -1359,6 +1380,12 @@ func (cc *CopyCommand) RunCommand() error {
1359
1380
LogInfo ("filter %d,name:%s,pattern:%s\n " , k , v .name , v .pattern )
1360
1381
}
1361
1382
1383
+ cc .cpOption .startTime , _ = GetInt (OptionStartTime , cc .command .options )
1384
+ cc .cpOption .endTime , _ = GetInt (OptionEndTime , cc .command .options )
1385
+ if cc .cpOption .endTime > 0 && cc .cpOption .startTime > cc .cpOption .endTime {
1386
+ return fmt .Errorf ("start time %d is larger than end time %d" , cc .cpOption .startTime , cc .cpOption .endTime )
1387
+ }
1388
+
1362
1389
//get file list
1363
1390
srcURLList , err := cc .getStorageURLs (cc .command .args [0 : len (cc .command .args )- 1 ])
1364
1391
if err != nil {
@@ -2113,6 +2140,14 @@ func (cc *CopyCommand) makeObjectName(destURL CloudURL, file fileInfoType) strin
2113
2140
}
2114
2141
2115
2142
func (cc * CopyCommand ) skipUpload (spath string , bucket * oss.Bucket , objectName string , destURL CloudURL , srcModifiedTime int64 ) (bool , error ) {
2143
+ if cc .cpOption .startTime > 0 && srcModifiedTime < cc .cpOption .startTime {
2144
+ return true , nil
2145
+ }
2146
+
2147
+ if cc .cpOption .endTime > 0 && srcModifiedTime > cc .cpOption .endTime {
2148
+ return true , nil
2149
+ }
2150
+
2116
2151
if cc .cpOption .snapshotPath != "" || cc .cpOption .update {
2117
2152
if cc .cpOption .snapshotPath != "" {
2118
2153
tstr , err := cc .cpOption .snapshotldb .Get ([]byte (spath ), nil )
@@ -2522,6 +2557,14 @@ func (cc *CopyCommand) makeFileName(relativeObject, filePath string) string {
2522
2557
}
2523
2558
2524
2559
func (cc * CopyCommand ) skipDownload (fileName string , srcModifiedTime time.Time , object string ) bool {
2560
+ if cc .cpOption .startTime > 0 && srcModifiedTime .Unix () < cc .cpOption .startTime {
2561
+ return true
2562
+ }
2563
+
2564
+ if cc .cpOption .endTime > 0 && srcModifiedTime .Unix () > cc .cpOption .endTime {
2565
+ return true
2566
+ }
2567
+
2525
2568
if cc .cpOption .snapshotPath != "" || cc .cpOption .update {
2526
2569
if cc .cpOption .snapshotPath != "" {
2527
2570
tstr , err := cc .cpOption .snapshotldb .Get ([]byte (object ), nil )
@@ -2986,6 +3029,14 @@ func (cc *CopyCommand) makeCopyObjectName(srcRelativeObject, destObject string)
2986
3029
}
2987
3030
2988
3031
func (cc * CopyCommand ) skipCopy (destURL CloudURL , destObject string , srct time.Time ) (bool , error ) {
3032
+ if cc .cpOption .startTime > 0 && srct .Unix () < cc .cpOption .startTime {
3033
+ return true , nil
3034
+ }
3035
+
3036
+ if cc .cpOption .endTime > 0 && srct .Unix () > cc .cpOption .endTime {
3037
+ return true , nil
3038
+ }
3039
+
2989
3040
destBucket , err := cc .command .ossBucket (destURL .bucket )
2990
3041
if err != nil {
2991
3042
return false , err
0 commit comments