-
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 24, 2015
1 parent
10eeb35
commit 7d9b937
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
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,32 @@ | ||
<?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 { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handle() { | ||
$connection = \OC::$server->getDatabaseConnection(); | ||
// TODO: SQLite... | ||
$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
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