Skip to content

Commit a4874ab

Browse files
committed
bugfix DownloadFromPeer for not distinct file
1 parent e8ef8aa commit a4874ab

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

fileserver.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,16 @@ func (this *Server) RepairStatByDate(date string) StatDateFileInfo {
993993
stat.TotalSize = fileSize
994994
return stat
995995
}
996+
func (this *Server) GetFilePathByInfo(fileInfo *FileInfo) string {
997+
var (
998+
fn string
999+
)
1000+
fn = fileInfo.Name
1001+
if fileInfo.ReName != "" {
1002+
fn = fileInfo.ReName
1003+
}
1004+
return DOCKER_DIR + fileInfo.Path + "/" + fn
1005+
}
9961006
func (this *Server) CheckFileExistByMd5(md5s string, fileInfo *FileInfo) bool { // important: just for DownloadFromPeer use
9971007
var (
9981008
err error
@@ -1090,7 +1100,10 @@ func (this *Server) DownloadFromPeer(peer string, fileInfo *FileInfo) {
10901100
if fileInfo.ReName != "" {
10911101
filename = fileInfo.ReName
10921102
}
1093-
if this.CheckFileExistByMd5(fileInfo.Md5, fileInfo) {
1103+
if this.CheckFileExistByMd5(fileInfo.Md5, fileInfo) && Config().EnableDistinctFile {
1104+
return
1105+
}
1106+
if !Config().EnableDistinctFile && this.util.FileExists(this.GetFilePathByInfo(fileInfo)) {
10941107
return
10951108
}
10961109
if _, err = os.Stat(fileInfo.Path); err != nil {

0 commit comments

Comments
 (0)