summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-11-28 13:17:19 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2013-11-28 13:31:08 +0100
commiteaedda2116ddde4b0a571ccdf96437eea37fe380 (patch)
tree84fab876b368dd5f947f22dcb6fb80083207a850 /apps/files_sharing
parenta1d2f0f51605b6c4b2a204e6650c683881052a1a (diff)
downloadnextcloud-server-eaedda2116ddde4b0a571ccdf96437eea37fe380.tar.gz
nextcloud-server-eaedda2116ddde4b0a571ccdf96437eea37fe380.zip
make sure that we don't try to access an already deleted files, fixes some file source not found warnings
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/updater.php23
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'];
}
/**