perf: 共享的文件禁止移动到另一个共享文件夹内

This commit is contained in:
kuaifan
2022-04-27 15:47:53 +08:00
parent 529b4bec31
commit 092506e9ab
3 changed files with 26 additions and 17 deletions

View File

@@ -363,6 +363,15 @@ class FileController extends AbstractController
$file = File::permissionFind($id, 1000);
//
if ($pid > 0) {
if ($toShareFile) {
if ($file->share) {
throw new ApiException("{$file->name} 当前正在共享,无法移动到另一个共享文件夹内");
}
if ($file->isSubShare()) {
throw new ApiException("{$file->name} 内含有共享文件,无法移动到另一个共享文件夹内");
}
}
//
$tmpId = $pid;
while ($tmpId > 0) {
if ($id == $tmpId) {
@@ -370,11 +379,6 @@ class FileController extends AbstractController
}
$tmpId = intval(File::whereId($tmpId)->value('pid'));
}
if ($file->share && $toShareFile) {
$file->share = 0;
$file->save();
FileUser::deleteFileAll($file->id, $file->userid);
}
}
//
$file->pid = $pid;
@@ -951,7 +955,7 @@ class FileController extends AbstractController
// 设置共享
$action = "update";
if ($force === 0) {
if (File::where("pids", "like", "%,{$file->id},%")->whereShare(1)->exists()) {
if ($file->isSubShare()) {
return Base::retError('此文件夹内已有共享文件夹', [], -3001);
}
}