Browse Source

Merge pull request #15787 from owncloud/trash-partfiles

Do not trash part files, delete directly
tags/v8.1.0alpha2
Morris Jobke 9 years ago
parent
commit
42d9ba0f83
2 changed files with 6 additions and 3 deletions
  1. 4
    1
      apps/files_trashbin/lib/storage.php
  2. 2
    2
      lib/private/connector/sabre/file.php

+ 4
- 1
apps/files_trashbin/lib/storage.php View File

* @param string $path * @param string $path
*/ */
public function unlink($path) { public function unlink($path) {
if (self::$disableTrash || !\OC_App::isEnabled('files_trashbin')) {
if (self::$disableTrash
|| !\OC_App::isEnabled('files_trashbin')
|| (pathinfo($path, PATHINFO_EXTENSION) === 'part')
) {
return $this->storage->unlink($path); return $this->storage->unlink($path);
} }
$normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path); $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);

+ 2
- 2
lib/private/connector/sabre/file.php View File

$target = $storage->fopen($internalPartPath, 'wb'); $target = $storage->fopen($internalPartPath, 'wb');
if ($target === false) { if ($target === false) {
\OC_Log::write('webdav', '\OC\Files\Filesystem::fopen() failed', \OC_Log::ERROR); \OC_Log::write('webdav', '\OC\Files\Filesystem::fopen() failed', \OC_Log::ERROR);
$this->fileView->unlink($partFilePath);
$storage->unlink($internalPartPath);
// because we have no clue about the cause we can only throw back a 500/Internal Server Error // because we have no clue about the cause we can only throw back a 500/Internal Server Error
throw new Exception('Could not write file contents'); throw new Exception('Could not write file contents');
} }
$fileExists = $storage->file_exists($internalPath); $fileExists = $storage->file_exists($internalPath);
if ($renameOkay === false || $fileExists === false) { if ($renameOkay === false || $fileExists === false) {
\OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR); \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
$this->fileView->unlink($partFilePath);
$storage->unlink($internalPartPath);
throw new Exception('Could not rename part file to final file'); throw new Exception('Could not rename part file to final file');
} }
} catch (\OCP\Files\LockNotAcquiredException $e) { } catch (\OCP\Files\LockNotAcquiredException $e) {

Loading…
Cancel
Save