1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/15699] Rewrite acp_storage

PHPBB3-15699
This commit is contained in:
Ruben Calvo
2023-09-22 16:52:22 +02:00
parent 4974f86059
commit 58ecd3b048
27 changed files with 954 additions and 621 deletions

View File

@@ -13,7 +13,7 @@
namespace phpbb\storage\adapter;
use phpbb\storage\exception\exception;
use phpbb\storage\exception\storage_exception;
interface adapter_interface
{
@@ -29,7 +29,7 @@ interface adapter_interface
*
* @param string $path
* @param string $content
* @throws exception When the file cannot be written
* @throws storage_exception When the file cannot be written
*/
public function put_contents(string $path, string $content): void;
@@ -39,7 +39,7 @@ interface adapter_interface
* @param string $path The file to read
*
* @return string Returns file contents
* @throws exception When cannot read file contents
* @throws storage_exception When cannot read file contents
*/
public function get_contents(string $path): string;
@@ -57,7 +57,7 @@ interface adapter_interface
*
* @param string $path file/directory to remove
*
* @throws exception When removal fails.
* @throws storage_exception When removal fails.
*/
public function delete(string $path): void;
@@ -67,7 +67,7 @@ interface adapter_interface
* @param string $path_orig The original file/direcotry
* @param string $path_dest The target file/directory
*
* @throws exception When file/directory cannot be renamed
* @throws storage_exception When file/directory cannot be renamed
*/
public function rename(string $path_orig, string $path_dest): void;
@@ -77,7 +77,7 @@ interface adapter_interface
* @param string $path_orig The original filename
* @param string $path_dest The target filename
*
* @throws exception When the file cannot be copied
* @throws storage_exception When the file cannot be copied
*/
public function copy(string $path_orig, string $path_dest): void;
@@ -94,7 +94,7 @@ interface adapter_interface
* Get space available in bytes
*
* @return float Returns available space
* @throws exception When unable to retrieve available storage space
* @throws storage_exception When unable to retrieve available storage space
*/
public function free_space(): float;
}

View File

@@ -14,7 +14,7 @@
namespace phpbb\storage\adapter;
use phpbb\storage\stream_interface;
use phpbb\storage\exception\exception;
use phpbb\storage\exception\storage_exception;
use phpbb\filesystem\exception\filesystem_exception;
use phpbb\filesystem\filesystem;
use phpbb\filesystem\helper as filesystem_helper;
@@ -117,7 +117,7 @@ class local implements adapter_interface, stream_interface
}
catch (filesystem_exception $e)
{
throw new exception('STORAGE_CANNOT_WRITE_FILE', $path, array(), $e);
throw new storage_exception('STORAGE_CANNOT_WRITE_FILE', $path, array(), $e);
}
}
@@ -130,7 +130,7 @@ class local implements adapter_interface, stream_interface
if ($content === false)
{
throw new exception('STORAGE_CANNOT_READ_FILE', $path);
throw new storage_exception('STORAGE_CANNOT_READ_FILE', $path);
}
return $content;
@@ -155,7 +155,7 @@ class local implements adapter_interface, stream_interface
}
catch (filesystem_exception $e)
{
throw new exception('STORAGE_CANNOT_DELETE', $path, array(), $e);
throw new storage_exception('STORAGE_CANNOT_DELETE', $path, array(), $e);
}
}
@@ -172,7 +172,7 @@ class local implements adapter_interface, stream_interface
}
catch (filesystem_exception $e)
{
throw new exception('STORAGE_CANNOT_RENAME', $path_orig, array(), $e);
throw new storage_exception('STORAGE_CANNOT_RENAME', $path_orig, array(), $e);
}
}
@@ -189,7 +189,7 @@ class local implements adapter_interface, stream_interface
}
catch (filesystem_exception $e)
{
throw new exception('STORAGE_CANNOT_COPY', $path_orig, array(), $e);
throw new storage_exception('STORAGE_CANNOT_COPY', $path_orig, array(), $e);
}
}
@@ -198,7 +198,7 @@ class local implements adapter_interface, stream_interface
*
* @param string $path The directory path
*
* @throws exception On any directory creation failure
* @throws storage_exception On any directory creation failure
*/
protected function create_dir(string $path): void
{
@@ -208,7 +208,7 @@ class local implements adapter_interface, stream_interface
}
catch (filesystem_exception $e)
{
throw new exception('STORAGE_CANNOT_CREATE_DIR', $path, array(), $e);
throw new storage_exception('STORAGE_CANNOT_CREATE_DIR', $path, array(), $e);
}
}
@@ -217,7 +217,7 @@ class local implements adapter_interface, stream_interface
*
* @param string $path The file path
*
* @throws exception On any directory creation failure
* @throws storage_exception On any directory creation failure
*/
protected function ensure_directory_exists(string $path): void
{
@@ -264,7 +264,7 @@ class local implements adapter_interface, stream_interface
if (!$stream)
{
throw new exception('STORAGE_CANNOT_OPEN_FILE', $path);
throw new storage_exception('STORAGE_CANNOT_OPEN_FILE', $path);
}
return $stream;
@@ -281,13 +281,13 @@ class local implements adapter_interface, stream_interface
if (!$stream)
{
throw new exception('STORAGE_CANNOT_CREATE_FILE', $path);
throw new storage_exception('STORAGE_CANNOT_CREATE_FILE', $path);
}
if (stream_copy_to_stream($resource, $stream) === false)
{
fclose($stream);
throw new exception('STORAGE_CANNOT_COPY_RESOURCE');
throw new storage_exception('STORAGE_CANNOT_COPY_RESOURCE');
}
fclose($stream);
@@ -298,10 +298,10 @@ class local implements adapter_interface, stream_interface
*
* @param string $path The file
*
* @throws exception When cannot get size
*
* @return array Properties
* @throws exception When cannot get size
* @throws storage_exception When cannot get size
*
* @throws storage_exception When cannot get size
*
*/
public function file_size(string $path): array
@@ -310,7 +310,7 @@ class local implements adapter_interface, stream_interface
if ($size === null)
{
throw new exception('STORAGE_CANNOT_GET_FILESIZE');
throw new storage_exception('STORAGE_CANNOT_GET_FILESIZE');
}
return ['size' => $size];
@@ -392,12 +392,12 @@ class local implements adapter_interface, stream_interface
if ($free_space === false)
{
throw new exception('STORAGE_CANNOT_GET_FREE_SPACE');
throw new storage_exception('STORAGE_CANNOT_GET_FREE_SPACE');
}
}
else
{
throw new exception('STORAGE_CANNOT_GET_FREE_SPACE');
throw new storage_exception('STORAGE_CANNOT_GET_FREE_SPACE');
}
return $free_space;