Fix some copy warning.
This commit is contained in:
parent
fc2df7e501
commit
bea9a0a56d
@ -383,7 +383,11 @@ func (this *DavService) prepareMoveCopy(
|
|||||||
panic(result.BadRequest("you cannot move the root directory"))
|
panic(result.BadRequest("you cannot move the root directory"))
|
||||||
}
|
}
|
||||||
|
|
||||||
destDirMatter = this.matterDao.CheckWithRootByPath(destinationDirPath, user)
|
destDirMatter = this.matterDao.FindWithRootByPath(destinationDirPath, user)
|
||||||
|
if destDirMatter == nil {
|
||||||
|
//throw conflict error
|
||||||
|
panic(result.CustomWebResult(result.CONFLICT, fmt.Sprintf("%s not exist", destinationDirPath)))
|
||||||
|
}
|
||||||
|
|
||||||
return srcMatter, destDirMatter, srcDirPath, destinationDirPath, destinationName, overwrite
|
return srcMatter, destDirMatter, srcDirPath, destinationDirPath, destinationName, overwrite
|
||||||
|
|
||||||
@ -411,6 +415,11 @@ func (this *DavService) HandleCopy(writer http.ResponseWriter, request *http.Req
|
|||||||
|
|
||||||
fmt.Printf("COPY %s\n", subPath)
|
fmt.Printf("COPY %s\n", subPath)
|
||||||
|
|
||||||
|
//debug point
|
||||||
|
if request.Header.Get("X-Litmus") == "copymove: 5 (copy_nodestcoll)" {
|
||||||
|
fmt.Println("stop here")
|
||||||
|
}
|
||||||
|
|
||||||
srcMatter, destDirMatter, _, _, destinationName, overwrite := this.prepareMoveCopy(writer, request, user, subPath)
|
srcMatter, destDirMatter, _, _, destinationName, overwrite := this.prepareMoveCopy(writer, request, user, subPath)
|
||||||
|
|
||||||
//copy to the new directory
|
//copy to the new directory
|
||||||
@ -418,6 +427,14 @@ func (this *DavService) HandleCopy(writer http.ResponseWriter, request *http.Req
|
|||||||
|
|
||||||
this.logger.Info("finish copying %s => %s", subPath, destDirMatter.Path)
|
this.logger.Info("finish copying %s => %s", subPath, destDirMatter.Path)
|
||||||
|
|
||||||
|
if overwrite {
|
||||||
|
//overwrite old. set the status code 204
|
||||||
|
writer.WriteHeader(http.StatusNoContent)
|
||||||
|
} else {
|
||||||
|
//copy new. set the status code 201
|
||||||
|
writer.WriteHeader(http.StatusCreated)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//lock.
|
//lock.
|
||||||
|
@ -528,7 +528,8 @@ func (this *MatterService) handleOverwrite(request *http.Request, user *User, de
|
|||||||
//delete.
|
//delete.
|
||||||
this.Delete(request, destMatter, user)
|
this.Delete(request, destMatter, user)
|
||||||
} else {
|
} else {
|
||||||
panic(result.BadRequestI18n(request, i18n.MatterExist, destMatter.Path))
|
//throw precondition failed. (RFC4918:10.6)
|
||||||
|
panic(result.CustomWebResult(result.PRECONDITION_FAILED, fmt.Sprintf("%s exists", destMatter.Path)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ var (
|
|||||||
NOT_FOUND = &CodeWrapper{Code: "NOT_FOUND", HttpStatus: http.StatusNotFound, Description: "404 not found"}
|
NOT_FOUND = &CodeWrapper{Code: "NOT_FOUND", HttpStatus: http.StatusNotFound, Description: "404 not found"}
|
||||||
METHOD_NOT_ALLOWED = &CodeWrapper{Code: "METHOD_NOT_ALLOWED", HttpStatus: http.StatusMethodNotAllowed, Description: "405 method not allowed"}
|
METHOD_NOT_ALLOWED = &CodeWrapper{Code: "METHOD_NOT_ALLOWED", HttpStatus: http.StatusMethodNotAllowed, Description: "405 method not allowed"}
|
||||||
CONFLICT = &CodeWrapper{Code: "CONFLICT", HttpStatus: http.StatusConflict, Description: "409 conflict"}
|
CONFLICT = &CodeWrapper{Code: "CONFLICT", HttpStatus: http.StatusConflict, Description: "409 conflict"}
|
||||||
|
PRECONDITION_FAILED = &CodeWrapper{Code: "PRECONDITION_FAILED", HttpStatus: http.StatusPreconditionFailed, Description: "412 precondition failed"}
|
||||||
UNSUPPORTED_MEDIA_TYPE = &CodeWrapper{Code: "UNSUPPORTED_MEDIA_TYPE", HttpStatus: http.StatusUnsupportedMediaType, Description: "415 conflict"}
|
UNSUPPORTED_MEDIA_TYPE = &CodeWrapper{Code: "UNSUPPORTED_MEDIA_TYPE", HttpStatus: http.StatusUnsupportedMediaType, Description: "415 conflict"}
|
||||||
RANGE_NOT_SATISFIABLE = &CodeWrapper{Code: "RANGE_NOT_SATISFIABLE", HttpStatus: http.StatusRequestedRangeNotSatisfiable, Description: "range not satisfiable"}
|
RANGE_NOT_SATISFIABLE = &CodeWrapper{Code: "RANGE_NOT_SATISFIABLE", HttpStatus: http.StatusRequestedRangeNotSatisfiable, Description: "range not satisfiable"}
|
||||||
NOT_INSTALLED = &CodeWrapper{Code: "NOT_INSTALLED", HttpStatus: http.StatusInternalServerError, Description: "application not installed"}
|
NOT_INSTALLED = &CodeWrapper{Code: "NOT_INSTALLED", HttpStatus: http.StatusInternalServerError, Description: "application not installed"}
|
||||||
@ -61,6 +62,8 @@ func FetchHttpStatus(code string) int {
|
|||||||
return METHOD_NOT_ALLOWED.HttpStatus
|
return METHOD_NOT_ALLOWED.HttpStatus
|
||||||
} else if code == CONFLICT.Code {
|
} else if code == CONFLICT.Code {
|
||||||
return CONFLICT.HttpStatus
|
return CONFLICT.HttpStatus
|
||||||
|
} else if code == PRECONDITION_FAILED.Code {
|
||||||
|
return PRECONDITION_FAILED.HttpStatus
|
||||||
} else if code == UNSUPPORTED_MEDIA_TYPE.Code {
|
} else if code == UNSUPPORTED_MEDIA_TYPE.Code {
|
||||||
return UNSUPPORTED_MEDIA_TYPE.HttpStatus
|
return UNSUPPORTED_MEDIA_TYPE.HttpStatus
|
||||||
} else if code == RANGE_NOT_SATISFIABLE.Code {
|
} else if code == RANGE_NOT_SATISFIABLE.Code {
|
||||||
|
@ -128,7 +128,11 @@ func GetFilenameOfPath(fullPath string) string {
|
|||||||
func DeleteEmptyDir(dirPath string) bool {
|
func DeleteEmptyDir(dirPath string) bool {
|
||||||
dir, err := ioutil.ReadDir(dirPath)
|
dir, err := ioutil.ReadDir(dirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(result.BadRequest("occur error while reading %s %s", dirPath, err.Error()))
|
if strings.Contains(err.Error(), "The system cannot find") {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
panic(result.BadRequest("occur error while reading %s %s", dirPath, err.Error()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(dir) == 0 {
|
if len(dir) == 0 {
|
||||||
//empty dir
|
//empty dir
|
||||||
|
Loading…
Reference in New Issue
Block a user