Skip to content

Commit ae6b0f5

Browse files
committed
Use the cache tags correctly.
1 parent cec5499 commit ae6b0f5

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

app/Http/Controllers/Admin/NodesController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function setToken(Request $request, $id)
366366
$node = Models\Node::findOrFail($id);
367367

368368
$token = str_random(32);
369-
Cache::put('NodeConfiguration:' . $token, $node->id, 5);
369+
Cache::tags(['Node:Configuration'])->put($token, $node->id, 5);
370370

371371
return response()->json(['token' => $token]);
372372
}

app/Http/Controllers/Daemon/ActionController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ActionController extends Controller
4040
*/
4141
public function authenticateDownload(Request $request)
4242
{
43-
$download = Cache::pull('Download:' . $request->input('token'));
43+
$download = Cache::tags(['Server:Downloads'])->pull($request->input('token'));
4444

4545
if (is_null($download)) {
4646
return response()->json([
@@ -81,7 +81,7 @@ public function markInstall(Request $request)
8181
$server->installed = ($status === 'installed') ? 1 : 2;
8282
$server->save();
8383

84-
return response('', 204);
84+
return response()->json([]);
8585
}
8686

8787
/**
@@ -93,7 +93,7 @@ public function markInstall(Request $request)
9393
*/
9494
public function configuration(Request $request, $token)
9595
{
96-
$nodeId = Cache::pull('NodeConfiguration:' . $token);
96+
$nodeId = Cache::tags(['Node:Configuration'])->pull($token);
9797
if (is_null($nodeId)) {
9898
return response()->json(['error' => 'token_invalid'], 403);
9999
}

app/Http/Controllers/Server/ServerController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ public function getDownloadFile(Request $request, $uuid, $file)
202202
$this->authorize('download-files', $server);
203203

204204
$token = str_random(40);
205-
Cache::tags(['Downloads', 'Downloads:Server:' . $server->uuid])->put('Download:' . $token, [
205+
Cache::tags(['Server:Downloads'])->put($token, [
206206
'server' => $server->uuid,
207207
'path' => $file,
208-
], 1);
208+
], 5);
209209

210210
return redirect($server->node->scheme . '://' . $server->node->fqdn . ':' . $server->node->daemonListen . '/server/file/download/' . $token);
211211
}

0 commit comments

Comments
 (0)