add snapshot redirect

This commit is contained in:
Alex Grintsvayg 2019-09-13 15:07:46 -04:00
parent fbbba49d24
commit 7a42856d32
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5
2 changed files with 19 additions and 0 deletions

View file

@ -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';

View file

@ -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
*/