[Pkg-owncloud-commits] [owncloud] 294/457: add proper locking to file_put_contents when using streams
David Prévot
taffit at moszumanska.debian.org
Sun Jun 28 20:06:26 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit 6b0874203d3dc77bf4ff274add5a7d7844e791b8
Author: Robin Appelman <icewind at owncloud.com>
Date: Wed Jun 3 16:23:43 2015 +0200
add proper locking to file_put_contents when using streams
---
lib/private/files/view.php | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index b98842f..1b49221 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -535,25 +535,37 @@ class View {
) {
$path = $this->getRelativePath($absolutePath);
+ $this->lockFile($path, ILockingProvider::LOCK_SHARED);
+
$exists = $this->file_exists($path);
$run = true;
if ($this->shouldEmitHooks($path)) {
$this->emit_file_hooks_pre($exists, $path, $run);
}
if (!$run) {
+ $this->unlockFile($path, ILockingProvider::LOCK_SHARED);
return false;
}
- $target = $this->fopen($path, 'w');
+
+ $this->changeLock($path, ILockingProvider::LOCK_EXCLUSIVE);
+
+ /** @var \OC\Files\Storage\Storage $storage */
+ list($storage, $internalPath) = $this->resolvePath($path);
+ $target = $storage->fopen($internalPath, 'w');
if ($target) {
- list ($count, $result) = \OC_Helper::streamCopy($data, $target);
+ list (, $result) = \OC_Helper::streamCopy($data, $target);
fclose($target);
fclose($data);
$this->updater->update($path);
+
+ $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE);
+
if ($this->shouldEmitHooks($path) && $result !== false) {
$this->emit_file_hooks_post($exists, $path);
}
return $result;
} else {
+ $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE);
return false;
}
} else {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list