Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where failure to rename a file from the temp prefix to the file name would not be considered a Failed transfer #2481

Merged
merged 3 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions e2etest/zt_basic_copy_sync_remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ func TestBasic_CopyDownloadSingleBlob(t *testing.T) {
}, EAccountType.Standard(), EAccountType.Standard(), "")
}

func TestBasic_CopyDownloadSingleBlobEmptyDir(t *testing.T) {
// Only Windows fails to rename if there is an empty dir name in the path
if runtime.GOOS != "windows" {
return
}
RunScenarios(t, eOperation.Copy(), eTestFromTo.Other(common.EFromTo.BlobLocal()), eValidate.Auto(), allCredentialTypes, anonymousAuthOnly, params{
recursive: true,
}, nil, testFiles{
defaultSize: "1K",
shouldTransfer: []interface{}{
folder(""),
},
shouldFail: []interface{}{
f("dir1//dir3/file1.txt"),
},
}, EAccountType.Standard(), EAccountType.Standard(), "")
}

func TestBasic_CopyDownloadEmptyBlob(t *testing.T) {
RunScenarios(t, eOperation.CopyAndSync(), eTestFromTo.AllDownloads(), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
Expand Down
6 changes: 2 additions & 4 deletions ste/xfer-remoteToLocal-file.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,13 @@ func epilogueWithCleanupDownload(jptm IJobPartTransferMgr, dl downloader, active
}

// check if we need to rename back to original name. At this point, we're sure the file is completely
// downloaded and not corrupt. In fact, post this point we should only log errors and
// not fail the transfer.
// downloaded and not corrupt.
renameNecessary := !strings.EqualFold(info.getDownloadPath(), info.Destination) &&
!strings.EqualFold(info.Destination, common.Dev_Null)
if err == nil && renameNecessary {
renameErr := os.Rename(info.getDownloadPath(), info.Destination)
if renameErr != nil {
jptm.LogError(info.Destination, fmt.Sprintf(
"Failed to rename. File at %s", info.getDownloadPath()), renameErr)
jptm.FailActiveDownload("Download rename", renameErr)
}
}
}
Expand Down