diff --git a/handle/handle.go b/handle/handle.go index d0a641f..4c1e80c 100644 --- a/handle/handle.go +++ b/handle/handle.go @@ -33,7 +33,7 @@ var gobalLoginUserId string //key:filepath,value:hash var gobalFileMap = make(map[string] string) -var gobalFileUpdateTimeMap = make(map[string] string) +var gobalFileDownLoadingMap = make(map[string] int) //手动上传文件,非自动上传 var goabalAddFileMap = make(map[string] int) @@ -163,6 +163,9 @@ func DownCommand(conn *websocket.Conn, hash, projectName, fileName, nodeDir stri //下载启动标识,有下载进度则设置为true var downloading bool = false + //正在下载标识,标识用于不监测更新改动 + gobalFileDownLoadingMap[fmt.Sprint(fileDir+"\\"+fileName)]=1 + //构建本地cmd执行 ipfs get progress := make(chan string,10000) var stdout, stderr []byte @@ -270,6 +273,7 @@ func DownCommand(conn *websocket.Conn, hash, projectName, fileName, nodeDir stri config.GobalWatchChannelMap[config.LocalWorkSpaceDir+gobalLoginUserName+"\\"+projectName] <- ";" log.Printf("叮,资源文件[ %v ]下载完成",fileName) + defer time.Sleep(5*time.Second);gobalFileDownLoadingMap[fmt.Sprint(fileDir+"\\"+fileName)]=0 defer close(progress) return nil } @@ -724,7 +728,7 @@ func postUpdateFile(projectName, folderName, relativePath, ipfsCid, fileName, hi log.Printf("字符串%v反序列化出错", string(b[:])) return err } - log.Println("资源[ %v ]服务记录更新成功",fileName) + log.Printf("资源[ %v ]服务记录更新成功",fileName) return nil } @@ -788,7 +792,7 @@ func commitRecord(path,currentHistoryHash,hash,note,creator string, milestone bo commitHistory.CreateTime=time.Now().Unix() if commitHistory.ParentHash==commitHistory.CurrentHash{ - return commitHistory.Version,commitHistory.CurrentHash,nil + return commitHistory.Version,currentHistoryHash,nil } file,err :=os.OpenFile(path,os.O_APPEND,0666) @@ -1047,7 +1051,7 @@ func SubscriptionFileChange(conn *websocket.Conn, projectName string) error{ queryKey := strings.Replace(actionAndModifyFilePath[1],config.LocalWorkSpaceDir,"",1) //当前登陆用户判断 - if gobalLoginUserName != strings.Split(queryKey,"\\")[0]{ + if gobalLoginUserName != strings.Split(queryKey,"\\")[0] && actionAndModifyFilePathStr!=";"{ log.Printf("非法用户修改%v", actionAndModifyFilePathStr) continue } @@ -1071,6 +1075,11 @@ func SubscriptionFileChange(conn *websocket.Conn, projectName string) error{ continue } + //更新判断 + if gobalFileDownLoadingMap[actionAndModifyFilePath[1]]==1{ + continue + } + oldValue := strings.Split(querymap[queryKey],";") newValue := oldValue[0]+";" +"1" err = etcdclient.ReplaceInto(queryKey,newValue) @@ -1115,7 +1124,7 @@ func SubscriptionFileChange(conn *websocket.Conn, projectName string) error{ continue } GobalMessageNotify <- fmt.Sprintf("文件更新成功\n%v",fileName) - + continue }else if actionAndModifyFilePath[0]=="create"{ querymap,err := etcdclient.QueryWithPrefix(queryKey) if err != nil { @@ -1125,6 +1134,10 @@ func SubscriptionFileChange(conn *websocket.Conn, projectName string) error{ if len(querymap)==0{ continue } + //更新判断 + if gobalFileDownLoadingMap[actionAndModifyFilePath[1]]==1{ + continue + } oldValue := strings.Split(querymap[queryKey],";") newValue := oldValue[0]+";" +"1" @@ -1171,6 +1184,7 @@ func SubscriptionFileChange(conn *websocket.Conn, projectName string) error{ continue } GobalMessageNotify <- fmt.Sprintf("文件更新成功\n%v",fileName) + continue } err = sendFileListFromEtcd(keyPrefix,projectName,conn) if err != nil {