|
@@ 41-54 (lines=14) @@
|
| 38 |
|
* @param string $uuid |
| 39 |
|
* @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\BinaryFileResponse |
| 40 |
|
*/ |
| 41 |
|
public function pull(Request $request, $uuid) |
| 42 |
|
{ |
| 43 |
|
$pack = Models\Pack::where('uuid', $uuid)->first(); |
| 44 |
|
|
| 45 |
|
if (! $pack) { |
| 46 |
|
return response()->json(['error' => 'No such pack.'], 404); |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
if (! Storage::exists('packs/' . $pack->uuid . '/archive.tar.gz')) { |
| 50 |
|
return response()->json(['error' => 'There is no archive available for this pack.'], 503); |
| 51 |
|
} |
| 52 |
|
|
| 53 |
|
return response()->download(storage_path('app/packs/' . $pack->uuid . '/archive.tar.gz')); |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
/** |
| 57 |
|
* Returns the hash information for a pack. |
|
@@ 63-78 (lines=16) @@
|
| 60 |
|
* @param string $uuid |
| 61 |
|
* @return \Illuminate\Http\JsonResponse |
| 62 |
|
*/ |
| 63 |
|
public function hash(Request $request, $uuid) |
| 64 |
|
{ |
| 65 |
|
$pack = Models\Pack::where('uuid', $uuid)->first(); |
| 66 |
|
|
| 67 |
|
if (! $pack) { |
| 68 |
|
return response()->json(['error' => 'No such pack.'], 404); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
if (! Storage::exists('packs/' . $pack->uuid . '/archive.tar.gz')) { |
| 72 |
|
return response()->json(['error' => 'There is no archive available for this pack.'], 503); |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
return response()->json([ |
| 76 |
|
'archive.tar.gz' => sha1_file(storage_path('app/packs/' . $pack->uuid . '/archive.tar.gz')), |
| 77 |
|
]); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
/** |
| 81 |
|
* Pulls an update pack archive from the system. |