perf: 上传文件夹
This commit is contained in:
parent
e89ff02b59
commit
a6ba59eac0
@ -564,10 +564,11 @@ class FileController extends AbstractController
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
$dirs = explode("/", $webkitRelativePath);
|
$dirs = explode("/", $webkitRelativePath);
|
||||||
AbstractModel::transaction(function() use ($user, $userid, $dirs, &$pid) {
|
while (count($dirs) > 1) {
|
||||||
while (count($dirs) > 1) {
|
$dirName = array_shift($dirs);
|
||||||
$dirName = array_shift($dirs);
|
if ($dirName) {
|
||||||
if ($dirName) {
|
$pushMsg = [];
|
||||||
|
AbstractModel::transaction(function () use ($dirName, $user, $userid, &$pid, &$pushMsg) {
|
||||||
$dirRow = File::wherePid($pid)->whereType('folder')->whereName($dirName)->lockForUpdate()->first();
|
$dirRow = File::wherePid($pid)->whereType('folder')->whereName($dirName)->lockForUpdate()->first();
|
||||||
if (empty($dirRow)) {
|
if (empty($dirRow)) {
|
||||||
$dirRow = File::createInstance([
|
$dirRow = File::createInstance([
|
||||||
@ -578,17 +579,19 @@ class FileController extends AbstractController
|
|||||||
'created_id' => $user->userid,
|
'created_id' => $user->userid,
|
||||||
]);
|
]);
|
||||||
if ($dirRow->save()) {
|
if ($dirRow->save()) {
|
||||||
$tmpRow = File::find($dirRow->id);
|
$pushMsg[] = File::find($dirRow->id);
|
||||||
$tmpRow->pushMsg('add', $tmpRow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($dirRow)) {
|
if (empty($dirRow)) {
|
||||||
throw new ApiException('创建文件夹失败');
|
throw new ApiException('创建文件夹失败');
|
||||||
}
|
}
|
||||||
$pid = $dirRow->id;
|
$pid = $dirRow->id;
|
||||||
|
});
|
||||||
|
foreach ($pushMsg as $tmpRow) {
|
||||||
|
$tmpRow->pushMsg('add', $tmpRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
//
|
//
|
||||||
$path = 'uploads/file/' . date("Ym") . '/u' . $user->userid . '/';
|
$path = 'uploads/file/' . date("Ym") . '/u' . $user->userid . '/';
|
||||||
$data = Base::upload([
|
$data = Base::upload([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user