mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-22 16:22:58 +02:00
Merge pull request #5248 from rubencm/ticket/15692
[ticket/15692] Move checks if file exists from adapter to storage
This commit is contained in:
@@ -28,8 +28,7 @@ interface adapter_interface
|
||||
* @param string path The file to be written to.
|
||||
* @param string content The data to write into the file.
|
||||
*
|
||||
* @throws \phpbb\storage\exception\exception When the file already exists
|
||||
* When the file cannot be written
|
||||
* @throws \phpbb\storage\exception\exception When the file cannot be written
|
||||
*/
|
||||
public function put_contents($path, $content);
|
||||
|
||||
@@ -38,8 +37,7 @@ interface adapter_interface
|
||||
*
|
||||
* @param string $path The file to read
|
||||
*
|
||||
* @throws \phpbb\storage\exception\exception When the file doesn't exist
|
||||
* When cannot read file contents
|
||||
* @throws \phpbb\storage\exception\exception When cannot read file contents
|
||||
*
|
||||
* @return string Returns file contents
|
||||
*
|
||||
@@ -70,8 +68,7 @@ interface adapter_interface
|
||||
* @param string $path_orig The original file/direcotry
|
||||
* @param string $path_dest The target file/directory
|
||||
*
|
||||
* @throws \phpbb\storage\exception\exception When target exists
|
||||
* When file/directory cannot be renamed
|
||||
* @throws \phpbb\storage\exception\exception When file/directory cannot be renamed
|
||||
*/
|
||||
public function rename($path_orig, $path_dest);
|
||||
|
||||
@@ -81,8 +78,7 @@ interface adapter_interface
|
||||
* @param string $path_orig The original filename
|
||||
* @param string $path_dest The target filename
|
||||
*
|
||||
* @throws \phpbb\storage\exception\exception When target exists
|
||||
* When the file cannot be copied
|
||||
* @throws \phpbb\storage\exception\exception When the file cannot be copied
|
||||
*/
|
||||
public function copy($path_orig, $path_dest);
|
||||
|
||||
|
@@ -118,11 +118,6 @@ class local implements adapter_interface, stream_interface
|
||||
{
|
||||
$this->ensure_directory_exists($path);
|
||||
|
||||
if ($this->exists($path))
|
||||
{
|
||||
throw new exception('STORAGE_FILE_EXISTS', $path);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->filesystem->dump_file($this->root_path . $this->get_path($path) . $this->get_filename($path), $content);
|
||||
@@ -138,11 +133,6 @@ class local implements adapter_interface, stream_interface
|
||||
*/
|
||||
public function get_contents($path)
|
||||
{
|
||||
if (!$this->exists($path))
|
||||
{
|
||||
throw new exception('STORAGE_FILE_NO_EXIST', $path);
|
||||
}
|
||||
|
||||
$content = @file_get_contents($this->root_path . $this->get_path($path) . $this->get_filename($path));
|
||||
|
||||
if ($content === false)
|
||||
@@ -331,11 +321,6 @@ class local implements adapter_interface, stream_interface
|
||||
{
|
||||
$this->ensure_directory_exists($path);
|
||||
|
||||
if ($this->exists($path))
|
||||
{
|
||||
throw new exception('STORAGE_FILE_EXISTS', $path);
|
||||
}
|
||||
|
||||
$stream = @fopen($this->root_path . $this->get_path($path) . $this->get_filename($path), 'w+b');
|
||||
|
||||
if (!$stream)
|
||||
@@ -363,7 +348,7 @@ class local implements adapter_interface, stream_interface
|
||||
*/
|
||||
public function file_size($path)
|
||||
{
|
||||
$size = filesize($this->root_path . $this->get_path($path) . $this->get_filename($path));
|
||||
$size = @filesize($this->root_path . $this->get_path($path) . $this->get_filename($path));
|
||||
|
||||
if ($size === null)
|
||||
{
|
||||
@@ -435,7 +420,7 @@ class local implements adapter_interface, stream_interface
|
||||
*/
|
||||
public function get_link($path)
|
||||
{
|
||||
return generate_board_url() . $this->path . $path;
|
||||
return generate_board_url() . '/' . $this->path . $path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user