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