summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2013-11-14 08:44:14 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2013-12-06 17:01:13 +0100
commit40f148cc6cb42ac24c04cff6dd4472d94cc1f097 (patch)
treed74f7b6d44b54ab2fdb77a4a676329115559ce70 /apps
parent6aa9daf4e6bec5c2c15b896f99b07ce9ebe310cf (diff)
downloadnextcloud-server-40f148cc6cb42ac24c04cff6dd4472d94cc1f097.tar.gz
nextcloud-server-40f148cc6cb42ac24c04cff6dd4472d94cc1f097.zip
Don't try to encrypt a file when the temp file isn't created
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/lib/util.php39
1 files changed, 21 insertions, 18 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 2ada62354c4..7f09a1f1f08 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