123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace OCA\Files_Sharing;
- use OC\BackgroundJob\TimedJob;
- class DeleteOrphanedSharesJob extends TimedJob {
-
- protected $defaultIntervalMin = 15;
-
- public function __construct() {
- $this->interval = $this->defaultIntervalMin * 60;
- }
-
- public function run($argument) {
- $connection = \OC::$server->getDatabaseConnection();
- $logger = \OC::$server->getLogger();
- $sql =
- 'DELETE FROM `*PREFIX*share` ' .
- 'WHERE `item_type` in (\'file\', \'folder\') ' .
- 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)';
- $deletedEntries = $connection->executeUpdate($sql);
- $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
- }
- }
|