init
This commit is contained in:
48
console/MoveController.php
Normal file
48
console/MoveController.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.kuvalda.ru/
|
||||
* @copyright
|
||||
* @license
|
||||
*/
|
||||
|
||||
namespace dominion\file\console;
|
||||
|
||||
use Yii;
|
||||
use yii\console\Controller;
|
||||
use yii\console\ExitCode;
|
||||
use dominion\file\File;
|
||||
|
||||
/**
|
||||
* залить файлы с диска на s3
|
||||
*
|
||||
* @author Rybkin Sasha <ribkin@dominion.ru>
|
||||
* @since 0.1
|
||||
*/
|
||||
class MoveController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* переносим данные с диска в s3
|
||||
* @return int Exit code
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$flag = true;
|
||||
$limit = 100;
|
||||
$offset = 0;
|
||||
while ($flag)
|
||||
{
|
||||
$models = File::find()->limit($limit)->offset($offset)->all();
|
||||
foreach ($models as $model)
|
||||
{
|
||||
$model->moveToS3(false);
|
||||
}
|
||||
$flag = count($models) == $limit;
|
||||
$offset += $limit;
|
||||
echo "перенесено: {$offset} \n";
|
||||
}
|
||||
return ExitCode::OK;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user