Lock files which are zipped

This commit is contained in:
Thomas Müller 2015-09-28 13:14:51 +02:00
parent 149792abe6
commit b5dce05cb6

View file

@ -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,6 +122,16 @@ 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);
@ -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() : '';