windows和linux路径修改
Former-commit-id: 54e5eee24cfe089fb275883bb48a775daa1554ac
This commit is contained in:
parent
b3a0c91d5e
commit
095ccb44e4
|
@ -25,7 +25,7 @@ func ChunkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
size, _ := strconv.ParseInt(r.PostFormValue("size"), 10, 64)
|
size, _ := strconv.ParseInt(r.PostFormValue("size"), 10, 64)
|
||||||
hash := r.PostFormValue("hash")
|
hash := r.PostFormValue("hash")
|
||||||
name := r.PostFormValue("name")
|
name := r.PostFormValue("name")
|
||||||
|
// 对比合并请求的文件大小和已上传文件夹大小
|
||||||
toSize, _ := getDirSize(path.Join(linuxUploadTempPath, hash))
|
toSize, _ := getDirSize(path.Join(linuxUploadTempPath, hash))
|
||||||
if size != toSize {
|
if size != toSize {
|
||||||
fmt.Fprintf(w, "文件上传错误")
|
fmt.Fprintf(w, "文件上传错误")
|
||||||
|
@ -51,7 +51,7 @@ func ChunkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
wg.Add(filesCount)
|
wg.Add(filesCount)
|
||||||
for i := 0; i < filesCount; i++ {
|
for i := 0; i < filesCount; i++ {
|
||||||
// 这里一定要注意按顺序读取不然文件就会损坏
|
// 这里一定要注意按顺序读取不然文件就会损坏
|
||||||
fileName := path.Join(chunksPath, "\\"+filesSort[strconv.Itoa(i)])
|
fileName := path.Join(chunksPath, "/"+filesSort[strconv.Itoa(i)])
|
||||||
data, err := ioutil.ReadFile(fileName)
|
data, err := ioutil.ReadFile(fileName)
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
fs.Write(data)
|
fs.Write(data)
|
||||||
|
@ -59,7 +59,7 @@ func ChunkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
os.RemoveAll(path.Join(chunksPath, "\\"))
|
os.RemoveAll(path.Join(chunksPath, "/"))
|
||||||
defer fs.Close()
|
defer fs.Close()
|
||||||
|
|
||||||
//// 加载镜像文件到docker
|
//// 加载镜像文件到docker
|
||||||
|
|
|
@ -22,7 +22,7 @@ type LoadBody struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var windowsUploadTempPath = strings.ReplaceAll(path.Join(windowsUploadPath, "temp"), "/", "\\")
|
var windowsUploadTempPath = strings.ReplaceAll(path.Join(windowsUploadPath, "temp"), "/", "\\")
|
||||||
var linuxUploadTempPath = path.Join(windowsUploadPath)
|
var linuxUploadTempPath = path.Join(linuxUploadPath)
|
||||||
|
|
||||||
func UploadImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func UploadImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -51,7 +51,7 @@ func UploadImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
if !isPathExists {
|
if !isPathExists {
|
||||||
err = os.MkdirAll(chunksPath, os.ModePerm)
|
err = os.MkdirAll(chunksPath, os.ModePerm)
|
||||||
}
|
}
|
||||||
destFile, err := os.OpenFile(path.Join(chunksPath+"\\"+hash+"-"+index), syscall.O_CREAT|syscall.O_WRONLY, 0777)
|
destFile, err := os.OpenFile(path.Join(chunksPath+"/"+hash+"-"+index), syscall.O_CREAT|syscall.O_WRONLY, 0777)
|
||||||
reader := bufio.NewReader(file)
|
reader := bufio.NewReader(file)
|
||||||
writer := bufio.NewWriter(destFile)
|
writer := bufio.NewWriter(destFile)
|
||||||
buf := make([]byte, 1024*1024) // 1M buf
|
buf := make([]byte, 1024*1024) // 1M buf
|
||||||
|
|
Loading…
Reference in New Issue