diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-09-28 13:14:51 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-05 16:53:57 +0200 |
commit | b5dce05cb6856cfd99bded35ca87b4a8c12813bd (patch) | |
tree | 20cc3564e3d6ed50f7ceac8f36dca5523772cfa6 | |
parent | 149792abe629c3105c7966ffb14c7514d4bcb3c5 (diff) | |
download | nextcloud-server-b5dce05cb6856cfd99bded35ca87b4a8c12813bd.tar.gz nextcloud-server-b5dce05cb6856cfd99bded35ca87b4a8c12813bd.zip |
Lock files which are zipped
-rw-r--r-- | lib/private/files.php | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/lib/private/files.php b/lib/private/files.php index 86ebf40cc57..5befda3bad5 100644 --- a/lib/private/files.php +++ b/lib/private/files.php @@ -40,7 +40,6 @@ * */ -use OC\Lock\NoopLockingProvider; use OC\Streamer; use OCP\Lock\ILockingProvider; @@ -63,10 +62,11 @@ class OC_Files { OC_Response::setContentDispositionHeader($name, 'attachment'); header('Content-Transfer-Encoding: binary'); OC_Response::disableCaching(); - $filesize = \OC\Files\Filesystem::filesize($filename); - header('Content-Type: '.\OC_Helper::getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename))); - if ($filesize > -1) { - OC_Response::setContentLengthHeader($filesize); + $fileSize = \OC\Files\Filesystem::filesize($filename); + $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename)); + header('Content-Type: '.$type); + if ($fileSize > -1) { + OC_Response::setContentLengthHeader($fileSize); } } @@ -122,7 +122,17 @@ class OC_Files { if ($getType === self::FILE) { $view->lockFile($filename, ILockingProvider::LOCK_SHARED); } - + if ($getType === self::ZIP_FILES) { + foreach ($files as $file) { + $file = $dir . '/' . $file; + $view->lockFile($file, ILockingProvider::LOCK_SHARED); + } + } + if ($getType === self::ZIP_DIR) { + $file = $dir . '/' . $files; + $view->lockFile($file, ILockingProvider::LOCK_SHARED); + } + if ($streamer) { $streamer->sendHeaders($name); } elseif (\OC\Files\Filesystem::isReadable($filename)) { @@ -166,6 +176,16 @@ class OC_Files { if ($getType === self::FILE) { $view->unlockFile($filename, ILockingProvider::LOCK_SHARED); } + if ($getType === self::ZIP_FILES) { + foreach ($files as $file) { + $file = $dir . '/' . $file; + $view->unlockFile($file, ILockingProvider::LOCK_SHARED); + } + } + if ($getType === self::ZIP_DIR) { + $file = $dir . '/' . $files; + $view->unlockFile($file, ILockingProvider::LOCK_SHARED); + } } catch (\OCP\Lock\LockedException $ex) { $l = \OC::$server->getL10N('core'); $hint = method_exists($ex, 'getHint') ? $ex->getHint() : ''; |