@@ -1133,7 +1133,8 @@ func (this *Server) DownloadFromPeer(peer string, fileInfo *FileInfo) {
11331133
11341134 fpath = DOCKER_DIR + fileInfo .Path + "/" + filename
11351135
1136- req .SetTimeout (time .Second * 5 , time .Second * 300 )
1136+ timeout := fileInfo .Size / 1024 / 1024 / 8 + 30
1137+ req .SetTimeout (time .Second * 5 , time .Second * time .Duration (timeout ))
11371138
11381139 if fileInfo .OffSet != - 1 { //small file download
11391140 data , err = req .Bytes ()
@@ -1219,7 +1220,6 @@ func (this *Server) Download(w http.ResponseWriter, r *http.Request) {
12191220
12201221 isPeer = this .IsPeer (r )
12211222
1222-
12231223 if Config ().DownloadUseToken && ! isPeer {
12241224
12251225 token = r .FormValue ("token" )
@@ -3531,10 +3531,10 @@ func (this *Server) initTus() {
35313531
35323532 BIG_DIR := STORE_DIR + "/_big/" + Config ().PeerId
35333533 os .MkdirAll (BIG_DIR , 0775 )
3534+ os .MkdirAll (LOG_DIR , 0775 )
35343535 store := filestore.FileStore {
35353536 Path : BIG_DIR ,
35363537 }
3537-
35383538 if fileLog , err = os .OpenFile (LOG_DIR + "/tusd.log" , os .O_CREATE | os .O_RDWR , 0666 ); err != nil {
35393539 log .Error (err )
35403540 fmt .Println (err )
@@ -3547,7 +3547,7 @@ func (this *Server) initTus() {
35473547 log .Error (err )
35483548
35493549 } else {
3550- if fi .Size () > 1024 * 1204 * 500 { //500M
3550+ if fi .Size () > 1024 * 1024 * 500 { //500M
35513551 this .util .CopyFile (LOG_DIR + "/tusd.log" , LOG_DIR + "/tusd.log.2" )
35523552 fileLog .Seek (0 , 0 )
35533553 fileLog .Truncate (0 )
@@ -3599,8 +3599,8 @@ func (this *Server) initTus() {
35993599 } else {
36003600 if fi .Md5 != "" {
36013601 log .Info (fmt .Sprintf ("file is found md5:%s" , fi .Md5 ))
3602- log .Info ("remove file:" ,oldFullPath )
3603- log .Info ("remove file:" ,infoFullPath )
3602+ log .Info ("remove file:" , oldFullPath )
3603+ log .Info ("remove file:" , infoFullPath )
36043604 os .Remove (oldFullPath )
36053605 os .Remove (infoFullPath )
36063606 continue
@@ -3625,7 +3625,7 @@ func (this *Server) initTus() {
36253625 }
36263626 os .Remove (infoFullPath )
36273627 this .postFileToPeer (fileInfo )
3628- this .SaveFileInfoToLevelDB (info .ID ,fileInfo )//add fileId to ldb
3628+ this .SaveFileInfoToLevelDB (info .ID , fileInfo ) //add fileId to ldb
36293629 this .SaveFileMd5Log (fileInfo , CONST_FILE_Md5_FILE_NAME )
36303630 }
36313631 }
0 commit comments