-
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.
Delete orphaned shares in a background job
- Loading branch information
Vincent Petry
committed
Mar 3, 2015
1 parent
be27188
commit ab5e634
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
apps/files_sharing/command/deleteorphanedsharescommand.php
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,30 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2015 Vincent Petry <[email protected]> | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. | ||
* See the COPYING-README file. | ||
*/ | ||
|
||
namespace OCA\Files_sharing\Command; | ||
|
||
use OCP\Command\ICommand; | ||
use OCP\IDBConnection; | ||
|
||
/** | ||
* Delete all share entries that have no matching entries in the file cache table. | ||
*/ | ||
class DeleteOrphanedSharesCommand implements ICommand { | ||
public function __construct() { | ||
} | ||
|
||
public function handle() { | ||
$connection = \OC::$server->getDatabaseConnection(); | ||
$connection->executeUpdate( | ||
'DELETE `s` FROM `*PREFIX*share` `s` ' . | ||
'LEFT JOIN `*PREFIX*filecache` `f` ON `s`.`file_source`=`f`.`fileid` ' . | ||
'WHERE `f`.`fileid` IS NULL;' | ||
); | ||
} | ||
|
||
} |
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