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