-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: previews are physically deleted from disk and db in an async ma…
…nner
- Loading branch information
1 parent
7e9caa4
commit ee94c75
Showing
11 changed files
with
380 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace OCA\Files\BackgroundJob; | ||
|
||
use OC\BackgroundJob\TimedJob; | ||
use OC\PreviewCleanup; | ||
|
||
class PreviewCleanupJob extends TimedJob { | ||
public function __construct() { | ||
$this->setInterval(3600); //execute job every hour | ||
} | ||
|
||
public function run($arguments) { | ||
$cmd = new PreviewCleanup(\OC::$server->getDatabaseConnection()); | ||
$count = $cmd->process(false, 10); | ||
$logger = \OC::$server->getLogger(); | ||
$logger->info("$count orphaned previews deleted"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* @author Thomas Müller <thomas.mueller@tmit.eu> | ||
* | ||
* @copyright Copyright (c) 2022, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
namespace OC\Core\Command\Previews; | ||
|
||
use Doctrine\DBAL\Platforms\MySqlPlatform; | ||
use Doctrine\DBAL\Platforms\OraclePlatform; | ||
use OC\Core\Command\Base; | ||
use OC\PreviewCleanup; | ||
use OCP\Files\Folder; | ||
use OCP\IDBConnection; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class Cleanup extends Base { | ||
|
||
/** | ||
* @var IDBConnection | ||
*/ | ||
private $connection; | ||
|
||
public function __construct(IDBConnection $connection) { | ||
parent::__construct(); | ||
$this->connection = $connection; | ||
} | ||
|
||
protected function configure() { | ||
parent::configure(); | ||
|
||
$this | ||
->setName('previews:cleanup') | ||
->setDescription('Remove unreferenced previews') | ||
->addOption('all') | ||
->addArgument('chunk_size', InputArgument::OPTIONAL, '', 1000) | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) { | ||
$all = $input->hasOption('all'); | ||
$chunk_size = $input->getArgument('chunk_size'); | ||
|
||
$pc = new PreviewCleanup($this->connection); | ||
$count = $pc->process($all, $chunk_size, static function ($userId, $name, $action) use ($output) { | ||
$output->writeln("$name - $userId: $action"); | ||
}); | ||
|
||
$output->writeln("$count orphaned previews deleted"); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.