diff options
Diffstat (limited to 'apps/files_sharing/lib/updater.php')
-rw-r--r-- | apps/files_sharing/lib/updater.php | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php index 0c35b18c42b..44ebb5cd3cd 100644 --- a/apps/files_sharing/lib/updater.php +++ b/apps/files_sharing/lib/updater.php @@ -23,6 +23,9 @@ namespace OC\Files\Cache; class Shared_Updater { + // shares which can be removed from oc_share after the delete operation was successful + static private $toRemove = array(); + /** * Correct the parent folders' ETags for all users shared the file at $target * @@ -58,15 +61,17 @@ class Shared_Updater { * @param string $path */ private static function removeShare($path) { - $fileInfo = \OC\Files\Filesystem::getFileInfo($path); - $fileSource = $fileInfo['fileid']; + $fileSource = self::$toRemove[$path]; - $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `file_source`=?'); - try { - \OC_DB::executeAudited($query, array($fileSource)); - } catch (\Exception $e) { - \OCP\Util::writeLog('files_sharing', "can't remove share: " . $e->getMessage(), \OCP\Util::WARN); + if (!\OC\Files\Filesystem::file_exists($path)) { + $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `file_source`=?'); + try { + \OC_DB::executeAudited($query, array($fileSource)); + } catch (\Exception $e) { + \OCP\Util::writeLog('files_sharing', "can't remove share: " . $e->getMessage(), \OCP\Util::WARN); + } } + unset(self::$toRemove[$path]); } /** @@ -89,6 +94,10 @@ class Shared_Updater { */ static public function deleteHook($params) { self::correctFolders($params['path']); + $fileInfo = \OC\Files\Filesystem::getFileInfo($params['path']); + // mark file as deleted so that we can clean up the share table if + // the file was deleted successfully + self::$toRemove[$params['path']] = $fileInfo['fileid']; } /** |