Folder cannot move to itself. fix #8
This commit is contained in:
parent
f67b7b3ca6
commit
e38520c0b0
@ -152,7 +152,7 @@ func PrepareConfigs() {
|
|||||||
filePath := GetConfPath() + "/tank.json"
|
filePath := GetConfPath() + "/tank.json"
|
||||||
content, err := ioutil.ReadFile(filePath)
|
content, err := ioutil.ReadFile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogWarning(fmt.Sprintf("无法找到配置文件,使用默认配置项:%s,%v", filePath, err))
|
LogWarning(fmt.Sprintf("无法找到配置文件:%s,错误:%v\n将使用config.go中的默认配置项。", filePath, err))
|
||||||
} else {
|
} else {
|
||||||
// 用 json.Unmarshal
|
// 用 json.Unmarshal
|
||||||
err := json.Unmarshal(content, CONFIG)
|
err := json.Unmarshal(content, CONFIG)
|
||||||
|
@ -410,7 +410,7 @@ func (this *MatterController) Move(writer http.ResponseWriter, request *http.Req
|
|||||||
return this.Error("destUuid参数必填")
|
return this.Error("destUuid参数必填")
|
||||||
} else {
|
} else {
|
||||||
if destUuid != "root" {
|
if destUuid != "root" {
|
||||||
destMatter = this.matterDao.FindByUuid(destUuid)
|
destMatter = this.matterService.Detail(destUuid)
|
||||||
|
|
||||||
if user.Role != USER_ROLE_ADMINISTRATOR && destMatter.UserUuid != user.Uuid {
|
if user.Role != USER_ROLE_ADMINISTRATOR && destMatter.UserUuid != user.Uuid {
|
||||||
return this.Error(RESULT_CODE_UNAUTHORIZED)
|
return this.Error(RESULT_CODE_UNAUTHORIZED)
|
||||||
@ -422,7 +422,7 @@ func (this *MatterController) Move(writer http.ResponseWriter, request *http.Req
|
|||||||
//验证src是否有问题。
|
//验证src是否有问题。
|
||||||
for _, uuid := range srcUuids {
|
for _, uuid := range srcUuids {
|
||||||
//找出该文件或者文件夹
|
//找出该文件或者文件夹
|
||||||
srcMatter := this.matterDao.FindByUuid(uuid)
|
srcMatter := this.matterDao.CheckByUuid(uuid)
|
||||||
|
|
||||||
if user.Role != USER_ROLE_ADMINISTRATOR && srcMatter.UserUuid != user.Uuid {
|
if user.Role != USER_ROLE_ADMINISTRATOR && srcMatter.UserUuid != user.Uuid {
|
||||||
return this.Error(RESULT_CODE_UNAUTHORIZED)
|
return this.Error(RESULT_CODE_UNAUTHORIZED)
|
||||||
@ -444,6 +444,16 @@ func (this *MatterController) Move(writer http.ResponseWriter, request *http.Req
|
|||||||
if srcMatter.UserUuid != destMatter.UserUuid {
|
if srcMatter.UserUuid != destMatter.UserUuid {
|
||||||
panic("文件和目标文件夹的拥有者不是同一人")
|
panic("文件和目标文件夹的拥有者不是同一人")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//文件夹不能把自己移入到自己中,也不可以移入到自己的子文件夹下。
|
||||||
|
tmpMatter := destMatter
|
||||||
|
for tmpMatter != nil {
|
||||||
|
if uuid == tmpMatter.Uuid {
|
||||||
|
panic("文件夹不能把自己移入到自己中,也不可以移入到自己的子文件夹下。")
|
||||||
|
}
|
||||||
|
tmpMatter = tmpMatter.Parent
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
srcMatters = append(srcMatters, srcMatter)
|
srcMatters = append(srcMatters, srcMatter)
|
||||||
|
Loading…
Reference in New Issue
Block a user