Skip to content

Commit

Permalink
[#] 优化路径兼容模式错误
Browse files Browse the repository at this point in the history
  • Loading branch information
WangNingkai committed Mar 22, 2021
1 parent bc0dce8 commit f232b5f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions app/Http/Controllers/DriveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,35 @@ class DriveController extends BaseController
*/
public function query(Request $request, $hash = '', $query = '')
{
if (!$hash) {
if (setting('single_account_mode', 1)) {
$query = $hash;
$hash = $request->get('hash', '');
if ($hash) {
$account_id = HashidsHelper::decode($hash);
} else {
$account_id = setting('primary_account', 0);
$hash = HashidsHelper::encode($account_id);
}

} else {
$account_id = HashidsHelper::decode($hash);
if (null === $account_id) {
$query = $hash;
$account_id = setting('primary_account', 0);
$hash = HashidsHelper::encode($account_id);
if (!$hash) {
$hash = $request->get('hash', '');
if ($hash) {
$account_id = HashidsHelper::decode($hash);
} else {
$account_id = setting('primary_account', 0);
$hash = HashidsHelper::encode($account_id);
}

} else {
$account_id = HashidsHelper::decode($hash);
if (null === $account_id) {
$query = $hash;
$account_id = setting('primary_account', 0);
$hash = HashidsHelper::encode($account_id);
}
}
}

if (!$account_id) {
abort(404, '尚未设置账号!');
}
Expand Down Expand Up @@ -91,7 +103,6 @@ public function query(Request $request, $hash = '', $query = '')
abort(404, '资源不存在!');
}
}

$service = $account->getOneDriveService();

$item = Cache::remember("d:item:{$account_id}:{$query}", setting('cache_expires'), function () use ($service, $query) {
Expand Down

0 comments on commit f232b5f

Please sign in to comment.