Skip to content

Commit

Permalink
bugfix DownloadFromPeer for not distinct file
Browse files Browse the repository at this point in the history
  • Loading branch information
sjqzhang committed Mar 12, 2019
1 parent e8ef8aa commit a4874ab
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion fileserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,16 @@ func (this *Server) RepairStatByDate(date string) StatDateFileInfo {
stat.TotalSize = fileSize
return stat
}
func (this *Server) GetFilePathByInfo(fileInfo *FileInfo) string {
var (
fn string
)
fn = fileInfo.Name
if fileInfo.ReName != "" {
fn = fileInfo.ReName
}
return DOCKER_DIR + fileInfo.Path + "/" + fn
}
func (this *Server) CheckFileExistByMd5(md5s string, fileInfo *FileInfo) bool { // important: just for DownloadFromPeer use
var (
err error
Expand Down Expand Up @@ -1090,7 +1100,10 @@ func (this *Server) DownloadFromPeer(peer string, fileInfo *FileInfo) {
if fileInfo.ReName != "" {
filename = fileInfo.ReName
}
if this.CheckFileExistByMd5(fileInfo.Md5, fileInfo) {
if this.CheckFileExistByMd5(fileInfo.Md5, fileInfo) && Config().EnableDistinctFile {
return
}
if !Config().EnableDistinctFile && this.util.FileExists(this.GetFilePathByInfo(fileInfo)) {
return
}
if _, err = os.Stat(fileInfo.Path); err != nil {
Expand Down

0 comments on commit a4874ab

Please sign in to comment.