From 9c7018e4fd29d541c3c5bcd65095e2cfff886c64 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 31 Oct 2012 23:36:49 -0700 Subject: [PATCH] [FileBackend] Check if paths are writable for delete ops too. * Also clarified the docs around isPathUsableInternal(). Change-Id: I3fc10fce43e040f45045d6da69f0211e9ab4155d --- includes/filebackend/FileBackendStore.php | 5 +++-- includes/filebackend/FileOp.php | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php index cb8be0b2cc..7e91949e68 100644 --- a/includes/filebackend/FileBackendStore.php +++ b/includes/filebackend/FileBackendStore.php @@ -72,8 +72,9 @@ abstract class FileBackendStore extends FileBackend { } /** - * Check if a file can be created at a given storage path. - * FS backends should check if the parent directory exists and the file is writable. + * Check if a file can be created or changed at a given storage path. + * FS backends should check if the parent directory exists, files can be + * written under it, and that any file already there is writable. * Backends using key/value stores should check if the container exists. * * @param $storagePath string diff --git a/includes/filebackend/FileOp.php b/includes/filebackend/FileOp.php index 20dfda2a35..ff1b604337 100644 --- a/includes/filebackend/FileOp.php +++ b/includes/filebackend/FileOp.php @@ -488,7 +488,7 @@ class StoreFileOp extends FileOp { $this->params['dst'], $this->backend->maxFileSizeInternal() ); $status->fatal( 'backend-fail-store', $this->params['src'], $this->params['dst'] ); return $status; - // Check if a file can be placed at the destination + // Check if a file can be placed/changed at the destination } elseif ( !$this->backend->isPathUsableInternal( $this->params['dst'] ) ) { $status->fatal( 'backend-fail-usable', $this->params['dst'] ); $status->fatal( 'backend-fail-store', $this->params['src'], $this->params['dst'] ); @@ -551,7 +551,7 @@ class CreateFileOp extends FileOp { $this->params['dst'], $this->backend->maxFileSizeInternal() ); $status->fatal( 'backend-fail-create', $this->params['dst'] ); return $status; - // Check if a file can be placed at the destination + // Check if a file can be placed/changed at the destination } elseif ( !$this->backend->isPathUsableInternal( $this->params['dst'] ) ) { $status->fatal( 'backend-fail-usable', $this->params['dst'] ); $status->fatal( 'backend-fail-create', $this->params['dst'] ); @@ -624,7 +624,7 @@ class CopyFileOp extends FileOp { $status->fatal( 'backend-fail-notexists', $this->params['src'] ); return $status; } - // Check if a file can be placed at the destination + // Check if a file can be placed/changed at the destination } elseif ( !$this->backend->isPathUsableInternal( $this->params['dst'] ) ) { $status->fatal( 'backend-fail-usable', $this->params['dst'] ); $status->fatal( 'backend-fail-copy', $this->params['src'], $this->params['dst'] ); @@ -700,7 +700,7 @@ class MoveFileOp extends FileOp { $status->fatal( 'backend-fail-notexists', $this->params['src'] ); return $status; } - // Check if a file can be placed at the destination + // Check if a file can be placed/changed at the destination } elseif ( !$this->backend->isPathUsableInternal( $this->params['dst'] ) ) { $status->fatal( 'backend-fail-usable', $this->params['dst'] ); $status->fatal( 'backend-fail-move', $this->params['src'], $this->params['dst'] ); @@ -781,6 +781,11 @@ class DeleteFileOp extends FileOp { $status->fatal( 'backend-fail-notexists', $this->params['src'] ); return $status; } + // Check if a file can be placed/changed at the source + } elseif ( !$this->backend->isPathUsableInternal( $this->params['src'] ) ) { + $status->fatal( 'backend-fail-usable', $this->params['src'] ); + $status->fatal( 'backend-fail-delete', $this->params['src'] ); + return $status; } // Update file existence predicates $predicates['exists'][$this->params['src']] = false; -- 2.20.1