mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 09:37:26 +00:00
add snapshot redirect
This commit is contained in:
parent
fbbba49d24
commit
7a42856d32
2 changed files with 19 additions and 0 deletions
|
@ -143,6 +143,8 @@ class Controller
|
|||
|
||||
$router->post('/i18n/set-culture', 'i18nActions::setCulture');
|
||||
|
||||
$router->get('/snapshot/{type}', 'DownloadActions::executeDownloadSnapshot');
|
||||
|
||||
$permanentRedirectsPath = ROOT_DIR . '/data/redirect/permanent.yaml';
|
||||
$tempRedirectsPath = ROOT_DIR . '/data/redirect/temporary.yaml';
|
||||
|
||||
|
|
|
@ -15,6 +15,23 @@ class DownloadActions extends Actions
|
|||
return Controller::redirect(GitHub::getRepoReleaseUrl($repo, OS::getOsForExtension($ext), $allowPrerelease) ?: '/get', 302);
|
||||
}
|
||||
|
||||
public static function executeDownloadSnapshot(string $type)
|
||||
{
|
||||
if (!in_array($type, ['blockchain', 'wallet'])) {
|
||||
return ['page/404'];
|
||||
}
|
||||
|
||||
$bucketName = "snapshots.lbry.com";
|
||||
$bucket = S3::getBucket($bucketName, "$type/");
|
||||
|
||||
if (!count($bucket)) {
|
||||
return ['page/404'];
|
||||
}
|
||||
|
||||
ksort($bucket);
|
||||
|
||||
return Controller::redirect("http://$bucketName/" . array_keys($bucket)[0], 302);
|
||||
}
|
||||
/*
|
||||
* this is a quick fix to add android, prob not proper design
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue