<commit_before>package lib 

import (
    "fmt"
    "strconv"
    "os"
    "time"
    "strings"
    
    oss "github.com/aliyun/aliyun-oss-go-sdk/oss"
    . "gopkg.in/check.v1"
)

func (s *OssutilCommandSuite) TestCPObject(c *C) {
    bucket := bucketNameCP 
    destBucket := bucketNameNotExist 

    // put object
    s.createFile(uploadFileName, content, c)
    object := "TestCPObject_cp" 
    s.putObject(bucket, object, uploadFileName, c)

    // get object
    s.getObject(bucket, object, downloadFileName, c)
    str := s.readFile(downloadFileName, c) 
    c.Assert(str, Equals, content)

    // modify uploadFile content
    data := "欢迎使用ossutil"
    s.createFile(uploadFileName, data, c)

    time.Sleep(sleepTime)
    // put to exist object
    s.putObject(bucket, object, uploadFileName, c)

    // get to exist file
    s.getObject(bucket, object, downloadFileName, c)
    str = s.readFile(downloadFileName, c) 
    c.Assert(str, Equals, data)

    // get without specify dest file 
    s.getObject(bucket, object, ".", c)
    str = s.readFile(object, c) 
    c.Assert(str, Equals, data)
    _ = os.Remove(object)

    // put without specify dest object 
    data1 := "put without specify dest object"
    s.createFile(uploadFileName, data1, c)
    s.putObject(bucket, "", uploadFileName, c)
    s.getObject(bucket, uploadFileName, downloadFileName, c)
    str = s.readFile(downloadFileName, c) 
    c.Assert(str, Equals, data1)

    // get to file in not exist directory
    notexistdir := "NOTEXISTDIR"
    s.getObject(bucket, object, notexistdir + string(os.PathSeparator) + downloadFileName, c)
    str = s.readFile(notexistdir + string(os.PathSeparator) + downloadFileName, c) 
    c.Assert(str, Equals, data)
    _ = os.RemoveAll(notexistdir)

    // copy file
    destObject := "TestCPObject_destObject"
    s.copyObject(bucket, object, bucket, destObject, c)

    objectStat := s.getStat(bucket, destObject, c)
    c.Assert(objectStat[StatACL], Equals, "default")
    
    // get dest file
    filePath := downloadFileName + "1" 
    s.getObject(bucket, destObject, filePath, c)
    str = s.readFile(filePath, c) 
    c.Assert(str, Equals, data)
    _ = os.Remove(filePath)

    // put to not exist bucket
    showElapse, err := s.rawCP(uploadFileName, CloudURLToString(destBucket, object), false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // get not exist bucket
    showElapse, err = s.rawCP(CloudURLToString(destBucket, object), downloadFileName, false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // get not exist object
    showElapse, err = s.rawCP(CloudURLToString(bucket, "notexistobject"), downloadFileName, false, true, false, DefaultBigFileThreshold, CheckpointDir) 
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // copy to not exist bucket
    showElapse, err = s.rawCP(CloudURLToString(bucket, object), CloudURLToString(destBucket, destObject), false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // corse bucket copy
    destBucket = bucketNameDest

    s.copyObject(bucket, object, destBucket, destObject, c)

    s.getObject(destBucket, destObject, filePath, c)
    str = s.readFile(filePath, c) 
    c.Assert(str, Equals, data)
    _ = os.Remove(filePath)

    // copy single object in directory, test the name of dest object 
    srcObject := "a/b/c/d/e"
    s.putObject(bucket, srcObject, uploadFileName, c)
    time.Sleep(time.Second)

    s.copyObject(bucket, srcObject, destBucket, "", c)

    s.getObject(destBucket, "e", filePath, c)
    str = s.readFile(filePath, c)
    c.Assert(str, Equals, data1)
    _ = os.Remove(filePath)

    s.copyObject(bucket, srcObject, destBucket, "a/", c)

    s.getObject(destBucket, "a/e", filePath, c)
    str = s.readFile(filePath, c)
    c.Assert(str, Equals, data1)
    _ = os.Remove(filePath)

    s.copyObject(bucket, srcObject, destBucket, "a", c)

    s.getObject(destBucket, "a", filePath, c)
    str = s.readFile(filePath, c)
    c.Assert(str, Equals, data1)
    _ = os.Remove(filePath)

    // copy without specify dest object
    s.copyObject(bucket, uploadFileName, destBucket, "", c)
    s.getObject(destBucket, uploadFileName, filePath, c)
    str = s.readFile(filePath, c) 
    c.Assert(str, Equals, data1)
    _ = os.Remove(filePath)
}

func (s *OssutilCommandSuite) TestErrorCP(c *C) {
    bucket := bucketNameExist 

    // error src_url
    showElapse, err := s.rawCP(uploadFileName, CloudURLToString("", ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(uploadFileName, CloudURLToString("", bucket), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString("", bucket), downloadFileName, true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString("", ""), downloadFileName, true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(uploadFileName, "a", true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // miss argc
    showElapse, err = s.rawCP(CloudURLToString("", bucket), "", true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // copy self
    object := "testobject"
    showElapse, err = s.rawCP(CloudURLToString(bucket, object), CloudURLToString(bucket, object), false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString(bucket, object), CloudURLToString(bucket, ""), false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), CloudURLToString(bucket, ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString(bucket, object), CloudURLToString(bucket, ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), CloudURLToString(bucket, object), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // err checkpoint dir, conflict with config file
    showElapse, err = s.rawCP(uploadFileName, CloudURLToString(bucket, object), false, true, true, DefaultBigFileThreshold, configFile)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)
}

func (s *OssutilCommandSuite) TestUploadErrSrc(c *C) {
    srcBucket := bucketNamePrefix + "uploadsrc"
    destBucket := bucketNameNotExist 
    command := "cp"
    args := []string{uploadFileName, CloudURLToString(srcBucket, ""), CloudURLToString(destBucket, "")}
    str := ""
    ok := true
    cpDir := CheckpointDir
    thre := strconv.FormatInt(DefaultBigFileThreshold, 10)
    routines := strconv.Itoa(Routines)
    options := OptionMapType{
        "endpoint": &str,
        "accessKeyID": &str,
        "accessKeySecret": &str,
        "stsToken": &str,
        "configFile": &configFile,
        "force": &ok,
        "bigfileThreshold": &thre,
        "checkpointDir": &cpDir,
        "routines": &routines,
    }
    showElapse, err := cm.RunCommand(command, args, options)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)
}

func (s *OssutilCommandSuite) TestBatchCPObject(c *C) {
    bucket := bucketNameBCP

    // create local dir
    dir := "TestBatchCPObject"
    err := os.MkdirAll(dir, 0755)
    c.Assert(err, IsNil)

    // upload empty dir miss recursive
    showElapse, err := s.rawCP(dir, CloudURLToString(bucket, ""), false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // upload empty dir
    showElapse, err = s.rawCP(dir, CloudURLToString(bucket, ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)

    // head object 
    showElapse, err = s.rawGetStat(bucket, dir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawGetStat(bucket, dir + "/")
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    _ = os.RemoveAll(dir)

    // create dir in dir 
    dir = "TestBatchCPObject_dir"
    subdir := "SUBDIR"
    err = os.MkdirAll(dir + string(os.PathSeparator) + subdir, 0755)
    c.Assert(err, IsNil)

    // upload dir    
    showElapse, err = s.rawCP(dir, CloudURLToString(bucket, ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true) 

    // remove object
    s.removeObjects(bucket, subdir + "/", false, true, c)

    // create file in dir
    num := 3 
    filePaths := []string{subdir + "/"}
    for i := 0; i < num; i++ {
        filePath := fmt.Sprintf("TestBatchCPObject_%d", i) 
        s.createFile(dir + "/" + filePath, fmt.Sprintf("测试文件：%d内容", i), c)
        filePaths = append(filePaths, filePath)
    }

    // upload files
    showElapse, err = s.rawCP(dir, CloudURLToString(bucket, ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)
    
    time.Sleep(7*time.Second)

    // get files
    downDir := "下载目录"
    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), downDir, true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)

    for _, filePath := range filePaths {
        _, err := os.Stat(downDir + "/" + filePath)
        c.Assert(err, IsNil)
    }

    _, err = os.Stat(downDir)
    c.Assert(err, IsNil)

    // get to exist files
    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), downDir, true, false, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)

    _, err = os.Stat(downDir)
    c.Assert(err, IsNil)

    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), downDir, true, false, true, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)

    _, err = os.Stat(downDir)
    c.Assert(err, IsNil)
    //c.Assert(f.ModTime(), Equals, f1.ModTime())

    // copy files
    destBucket := bucketNameNotExist 
    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), CloudURLToString(destBucket, "123"), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    destBucket = bucketNameDest

    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), CloudURLToString(destBucket, "123"), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)
    time.Sleep(7*time.Second)

    for _, filePath := range filePaths {
        s.getStat(destBucket, "123" + filePath, c)
    }

    // remove dir
    _ = os.RemoveAll(dir)
    _ = os.RemoveAll(downDir)
}

func (s *OssutilCommandSuite) TestCPObjectUpdate(c *C) {
    bucket := bucketNameExist 
    s.removeObjects(bucket, "", true, true, c)
    time.Sleep(2*7*time.Second) 

    // create older file and newer file
    oldData := "old data"
    oldFile := "oldFile"
    newData := "new data"
    newFile := "newFile"
    s.createFile(oldFile, oldData, c)
    time.Sleep(7*time.Second)
    s.createFile(newFile, newData, c)

    // put newer object
    object := "testobject"
    s.putObject(bucket, object, newFile, c)

    // get object
    s.getObject(bucket, object, downloadFileName, c)
    str := s.readFile(downloadFileName, c) 
    c.Assert(str, Equals, newData)

    // put old object with update
    showElapse, err := s.rawCP(oldFile, CloudURLToString(bucket, object), false, false, true, DefaultBigFileThreshold, CheckpointDir)  
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)
    time.Sleep(7*time.Second)<commit_msg>modify case<commit_after>package lib 

import (
    "fmt"
    "strconv"
    "os"
    "time"
    "strings"
    
    oss "github.com/aliyun/aliyun-oss-go-sdk/oss"
    . "gopkg.in/check.v1"
)

func (s *OssutilCommandSuite) TestCPObject(c *C) {
    bucket := bucketNameCP 
    destBucket := bucketNameNotExist 

    // put object
    s.createFile(uploadFileName, content, c)
    object := "TestCPObject_cp" 
    s.putObject(bucket, object, uploadFileName, c)

    // get object
    s.getObject(bucket, object, downloadFileName, c)
    str := s.readFile(downloadFileName, c) 
    c.Assert(str, Equals, content)

    // modify uploadFile content
    data := "欢迎使用ossutil"
    s.createFile(uploadFileName, data, c)

    time.Sleep(sleepTime)
    // put to exist object
    s.putObject(bucket, object, uploadFileName, c)

    // get to exist file
    s.getObject(bucket, object, downloadFileName, c)
    str = s.readFile(downloadFileName, c) 
    c.Assert(str, Equals, data)

    // get without specify dest file 
    s.getObject(bucket, object, ".", c)
    str = s.readFile(object, c) 
    c.Assert(str, Equals, data)
    _ = os.Remove(object)

    // put without specify dest object 
    data1 := "put without specify dest object"
    s.createFile(uploadFileName, data1, c)
    s.putObject(bucket, "", uploadFileName, c)
    s.getObject(bucket, uploadFileName, downloadFileName, c)
    str = s.readFile(downloadFileName, c) 
    c.Assert(str, Equals, data1)

    // get to file in not exist directory
    notexistdir := "NOTEXISTDIR"
    s.getObject(bucket, object, notexistdir + string(os.PathSeparator) + downloadFileName, c)
    str = s.readFile(notexistdir + string(os.PathSeparator) + downloadFileName, c) 
    c.Assert(str, Equals, data)
    _ = os.RemoveAll(notexistdir)

    // copy file
    destObject := "TestCPObject_destObject"
    s.copyObject(bucket, object, bucket, destObject, c)

    objectStat := s.getStat(bucket, destObject, c)
    c.Assert(objectStat[StatACL], Equals, "default")
    
    // get dest file
    filePath := downloadFileName + "1" 
    s.getObject(bucket, destObject, filePath, c)
    str = s.readFile(filePath, c) 
    c.Assert(str, Equals, data)
    _ = os.Remove(filePath)

    // put to not exist bucket
    showElapse, err := s.rawCP(uploadFileName, CloudURLToString(destBucket, object), false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // get not exist bucket
    showElapse, err = s.rawCP(CloudURLToString(destBucket, object), downloadFileName, false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // get not exist object
    showElapse, err = s.rawCP(CloudURLToString(bucket, "notexistobject"), downloadFileName, false, true, false, DefaultBigFileThreshold, CheckpointDir) 
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // copy to not exist bucket
    showElapse, err = s.rawCP(CloudURLToString(bucket, object), CloudURLToString(destBucket, destObject), false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // corse bucket copy
    destBucket = bucketNameDest

    s.copyObject(bucket, object, destBucket, destObject, c)

    s.getObject(destBucket, destObject, filePath, c)
    str = s.readFile(filePath, c) 
    c.Assert(str, Equals, data)
    _ = os.Remove(filePath)

    // copy single object in directory, test the name of dest object 
    srcObject := "a/b/c/d/e"
    s.putObject(bucket, srcObject, uploadFileName, c)
    time.Sleep(time.Second)

    s.copyObject(bucket, srcObject, destBucket, "", c)

    s.getObject(destBucket, "e", filePath, c)
    str = s.readFile(filePath, c)
    c.Assert(str, Equals, data1)
    _ = os.Remove(filePath)

    s.copyObject(bucket, srcObject, destBucket, "a/", c)

    s.getObject(destBucket, "a/e", filePath, c)
    str = s.readFile(filePath, c)
    c.Assert(str, Equals, data1)
    _ = os.Remove(filePath)

    s.copyObject(bucket, srcObject, destBucket, "a", c)

    s.getObject(destBucket, "a", filePath, c)
    str = s.readFile(filePath, c)
    c.Assert(str, Equals, data1)
    _ = os.Remove(filePath)

    // copy without specify dest object
    s.copyObject(bucket, uploadFileName, destBucket, "", c)
    s.getObject(destBucket, uploadFileName, filePath, c)
    str = s.readFile(filePath, c) 
    c.Assert(str, Equals, data1)
    _ = os.Remove(filePath)
}

func (s *OssutilCommandSuite) TestErrorCP(c *C) {
    bucket := bucketNameExist 

    // error src_url
    showElapse, err := s.rawCP(uploadFileName, CloudURLToString("", ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(uploadFileName, CloudURLToString("", bucket), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString("", bucket), downloadFileName, true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString("", ""), downloadFileName, true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(uploadFileName, "a", true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // miss argc
    showElapse, err = s.rawCP(CloudURLToString("", bucket), "", true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // copy self
    object := "testobject"
    showElapse, err = s.rawCP(CloudURLToString(bucket, object), CloudURLToString(bucket, object), false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString(bucket, object), CloudURLToString(bucket, ""), false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), CloudURLToString(bucket, ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString(bucket, object), CloudURLToString(bucket, ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), CloudURLToString(bucket, object), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // err checkpoint dir, conflict with config file
    showElapse, err = s.rawCP(uploadFileName, CloudURLToString(bucket, object), false, true, true, DefaultBigFileThreshold, configFile)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)
}

func (s *OssutilCommandSuite) TestUploadErrSrc(c *C) {
    srcBucket := bucketNamePrefix + "uploadsrc"
    destBucket := bucketNameNotExist 
    command := "cp"
    args := []string{uploadFileName, CloudURLToString(srcBucket, ""), CloudURLToString(destBucket, "")}
    str := ""
    ok := true
    cpDir := CheckpointDir
    thre := strconv.FormatInt(DefaultBigFileThreshold, 10)
    routines := strconv.Itoa(Routines)
    options := OptionMapType{
        "endpoint": &str,
        "accessKeyID": &str,
        "accessKeySecret": &str,
        "stsToken": &str,
        "configFile": &configFile,
        "force": &ok,
        "bigfileThreshold": &thre,
        "checkpointDir": &cpDir,
        "routines": &routines,
    }
    showElapse, err := cm.RunCommand(command, args, options)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)
}

func (s *OssutilCommandSuite) TestBatchCPObject(c *C) {
    bucket := bucketNameBCP

    // create local dir
    dir := "TestBatchCPObject"
    err := os.MkdirAll(dir, 0755)
    c.Assert(err, IsNil)

    // upload empty dir miss recursive
    showElapse, err := s.rawCP(dir, CloudURLToString(bucket, ""), false, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    // upload empty dir
    showElapse, err = s.rawCP(dir, CloudURLToString(bucket, ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)

    // head object 
    showElapse, err = s.rawGetStat(bucket, dir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    showElapse, err = s.rawGetStat(bucket, dir + "/")
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    _ = os.RemoveAll(dir)

    // create dir in dir 
    dir = "TestBatchCPObject_dir"
    subdir := "SUBDIR"
    err = os.MkdirAll(dir + string(os.PathSeparator) + subdir, 0755)
    c.Assert(err, IsNil)

    // upload dir    
    showElapse, err = s.rawCP(dir, CloudURLToString(bucket, ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true) 

    // remove object
    s.removeObjects(bucket, subdir + "/", false, true, c)

    // create file in dir
    num := 3 
    filePaths := []string{subdir + "/"}
    for i := 0; i < num; i++ {
        filePath := fmt.Sprintf("TestBatchCPObject_%d", i) 
        s.createFile(dir + "/" + filePath, fmt.Sprintf("测试文件：%d内容", i), c)
        filePaths = append(filePaths, filePath)
    }

    // upload files
    showElapse, err = s.rawCP(dir, CloudURLToString(bucket, ""), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)
    
    time.Sleep(7*time.Second)

    // get files
    downDir := "下载目录"
    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), downDir, true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)

    for _, filePath := range filePaths {
        _, err := os.Stat(downDir + "/" + filePath)
        c.Assert(err, IsNil)
    }

    _, err = os.Stat(downDir)
    c.Assert(err, IsNil)

    // get to exist files
    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), downDir, true, false, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)

    _, err = os.Stat(downDir)
    c.Assert(err, IsNil)

    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), downDir, true, false, true, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)

    _, err = os.Stat(downDir)
    c.Assert(err, IsNil)
    //c.Assert(f.ModTime(), Equals, f1.ModTime())

    // copy files
    destBucket := bucketNameNotExist 
    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), CloudURLToString(destBucket, "123"), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, NotNil)
    c.Assert(showElapse, Equals, false)

    destBucket = bucketNameDest

    showElapse, err = s.rawCP(CloudURLToString(bucket, ""), CloudURLToString(destBucket, "123"), true, true, false, DefaultBigFileThreshold, CheckpointDir)
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)
    time.Sleep(7*time.Second)

    for _, filePath := range filePaths {
        s.getStat(destBucket, "123" + filePath, c)
    }

    // remove dir
    _ = os.RemoveAll(dir)
    _ = os.RemoveAll(downDir)
}

func (s *OssutilCommandSuite) TestCPObjectUpdate(c *C) {
    bucket := bucketNameExist 
    s.removeObjects(bucket, "", true, true, c)
    time.Sleep(2*7*time.Second) 

    // create older file and newer file
    oldData := "old data"
    oldFile := "oldFile"
    newData := "new data"
    newFile := "newFile"
    s.createFile(oldFile, oldData, c)
    time.Sleep(7*time.Second)
    s.createFile(newFile, newData, c)

    // put newer object
    object := "testobject"
    s.putObject(bucket, object, newFile, c)

    // get object
    s.getObject(bucket, object, downloadFileName, c)
    str := s.readFile(downloadFileName, c) 
    c.Assert(str, Equals, newData)
    time.Sleep(time.Second)

    // put old object with update
    showElapse, err := s.rawCP(oldFile, CloudURLToString(bucket, object), false, false, true, DefaultBigFileThreshold, CheckpointDir)  
    c.Assert(err, IsNil)
    c.Assert(showElapse, Equals, true)
    //time.Sleep(7*time.Second)
{'fraction_non_alphanumeric': 0.12960911536635544, 'fraction_numerical': 0.0029276784301313498, 'mean_word_length': 3.5799963761551004, 'pattern_counts': {'":': 18, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '567228', 'n_tokens_mistral': 8649, 'n_tokens_neox': 8420, 'n_words': 1927}