[Pkg-owncloud-commits] [owncloud] 14/28: Don't try to encrypt a file when the temp file isn't created
David Prévot
taffit at moszumanska.debian.org
Sat Dec 7 02:33:31 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 281bbf4bd4ca0b2e565db0fb846f19b2b58d045f
Author: Bart Visscher <bartv at thisnet.nl>
Date: Thu Nov 14 08:44:14 2013 +0100
Don't try to encrypt a file when the temp file isn't created
---
apps/files_encryption/lib/util.php | 39 ++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index ef8d016..bf7c495 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -840,32 +840,35 @@ class Util {
// Open enc file handle for binary writing, with same filename as original plain file
$encHandle = fopen('crypt://' . $rawPath . '.part', 'wb');
- // Move plain file to a temporary location
- $size = stream_copy_to_stream($plainHandle, $encHandle);
+ if (is_resource($encHandle)) {
+ // Move plain file to a temporary location
+ $size = stream_copy_to_stream($plainHandle, $encHandle);
- fclose($encHandle);
- fclose($plainHandle);
+ fclose($encHandle);
+ fclose($plainHandle);
- $fakeRoot = $this->view->getRoot();
- $this->view->chroot('/' . $this->userId . '/files');
+ $fakeRoot = $this->view->getRoot();
+ $this->view->chroot('/' . $this->userId . '/files');
- $this->view->rename($relPath . '.part', $relPath);
+ $this->view->rename($relPath . '.part', $relPath);
- // set timestamp
- $this->view->touch($relPath, $timestamp);
+ // set timestamp
+ $this->view->touch($relPath, $timestamp);
- $this->view->chroot($fakeRoot);
+ $encSize = $this->view->filesize($relPath);
- // Add the file to the cache
- \OC\Files\Filesystem::putFileInfo($relPath, array(
- 'encrypted' => true,
- 'size' => $size,
- 'unencrypted_size' => $size,
- 'etag' => $fileInfo['etag']
- ));
+ $this->view->chroot($fakeRoot);
- $encryptedFiles[] = $relPath;
+ // Add the file to the cache
+ \OC\Files\Filesystem::putFileInfo($relPath, array(
+ 'encrypted' => true,
+ 'size' => $encSize,
+ 'unencrypted_size' => $size,
+ 'etag' => $fileInfo['etag']
+ ));
+ $encryptedFiles[] = $relPath;
+ }
}
// Encrypt legacy encrypted files
--
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