do not stat on url prepration. disable force flag

This commit is contained in:
Anand Babu (AB) Periasamy
2015-07-21 19:13:10 -07:00
parent b6e638fd36
commit 7c2f3fbe4e
4 changed files with 11 additions and 0 deletions
+4
View File
@@ -177,10 +177,13 @@ func prepareSingleCastURLsTypeA(sourceURL string, targetURL string) castURLs {
if !sourceContent.Type.IsRegular() { // Source is not a regular file
return castURLs{Error: NewIodine(iodine.New(errInvalidSource{URL: sourceURL}, nil))}
}
/* // Too expensive. Lets ignore it for now.
targetClient, err := target2Client(targetURL)
if err != nil {
return castURLs{Error: NewIodine(iodine.New(err, nil))}
}
// Target exists?
targetContent, err := targetClient.Stat()
if err == nil { // Target exists.
@@ -191,6 +194,7 @@ func prepareSingleCastURLsTypeA(sourceURL string, targetURL string) castURLs {
targetContents = append(targetContents, targetContent)
return castURLs{SourceContent: sourceContent, TargetContents: targetContents}
}
*/
// All OK.. We can proceed. Type A
sourceContent.Name = sourceURL
return castURLs{SourceContent: sourceContent, TargetContents: []*client.Content{{Name: targetURL}}}
+2
View File
@@ -159,6 +159,7 @@ func doPrepareCastURLs(session *sessionV2, trapCh <-chan bool) {
console.Errorln(sURLs.Error)
break
}
/* We are going to copy any way now. Let it fail at the time of putObject
if !globalForceFlag {
if len(sURLs.TargetContents) > 0 {
if sURLs.TargetContents[0].Size != 0 || !sURLs.TargetContents[0].Time.IsZero() {
@@ -168,6 +169,7 @@ func doPrepareCastURLs(session *sessionV2, trapCh <-chan bool) {
}
}
}
*/
jsonData, err := json.Marshal(sURLs)
if err != nil {
+2
View File
@@ -147,6 +147,7 @@ func doPrepareCopyURLs(session *sessionV2, trapCh <-chan bool) {
console.Errorln(cpURLs.Error)
break
}
/* Too expensive. Ignore this for now. Let it fail while putObject.
if !globalForceFlag {
if cpURLs.TargetContent.Size != 0 || !cpURLs.TargetContent.Time.IsZero() {
console.Fatalf("Destination already exists, cannot overwrite ‘%s’ with ‘%s’. "+
@@ -154,6 +155,7 @@ func doPrepareCopyURLs(session *sessionV2, trapCh <-chan bool) {
break
}
}
*/
jsonData, err := json.Marshal(cpURLs)
if err != nil {
+3
View File
@@ -97,11 +97,13 @@ func prepareCopyURLsTypeA(sourceURL string, targetURL string) <-chan copyURLs {
copyURLsCh <- copyURLs{Error: NewIodine(iodine.New(errInvalidSource{URL: sourceURL}, nil))}
return
}
/* Too expensive. Ignore this for now. Let it fail while putObject.
targetClient, err := target2Client(targetURL)
if err != nil {
copyURLsCh <- copyURLs{Error: NewIodine(iodine.New(err, nil))}
return
}
// Target exists?
targetContent, err := targetClient.Stat()
if err == nil { // Target exists.
@@ -112,6 +114,7 @@ func prepareCopyURLsTypeA(sourceURL string, targetURL string) <-chan copyURLs {
copyURLsCh <- copyURLs{SourceContent: sourceContent, TargetContent: targetContent}
return
}
*/
// All OK.. We can proceed. Type A
sourceContent.Name = sourceURL
copyURLsCh <- copyURLs{SourceContent: sourceContent, TargetContent: &client.Content{Name: targetURL}}