mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-14 11:35:33 +02:00
[ticket/15342] Small improvements to storage
PHPBB3-15342
This commit is contained in:
parent
28c0db86cf
commit
cc7178a6e0
@ -189,6 +189,8 @@ class acp_database
|
|||||||
|
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
|
|
||||||
|
$storage->track_file($file);
|
||||||
|
|
||||||
// Remove file from tmp
|
// Remove file from tmp
|
||||||
@unlink($temp_dir . '/' . $file);
|
@unlink($temp_dir . '/' . $file);
|
||||||
|
|
||||||
|
@ -248,6 +248,7 @@ class upload
|
|||||||
$fp = fopen($destination, 'rb');
|
$fp = fopen($destination, 'rb');
|
||||||
$this->storage->write_stream($destination_name, $fp);
|
$this->storage->write_stream($destination_name, $fp);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
|
$this->storage->track_file($destination_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -95,17 +95,10 @@ class storage
|
|||||||
* When the file cannot be written
|
* When the file cannot be written
|
||||||
*/
|
*/
|
||||||
public function put_contents($path, $content)
|
public function put_contents($path, $content)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
$this->get_adapter()->put_contents($path, $content);
|
$this->get_adapter()->put_contents($path, $content);
|
||||||
$this->track_file($path);
|
$this->track_file($path);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the contents of a file
|
* Read the contents of a file
|
||||||
@ -143,17 +136,10 @@ class storage
|
|||||||
* @throws \phpbb\storage\exception\exception When removal fails.
|
* @throws \phpbb\storage\exception\exception When removal fails.
|
||||||
*/
|
*/
|
||||||
public function delete($path)
|
public function delete($path)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
$this->get_adapter()->delete($path);
|
$this->get_adapter()->delete($path);
|
||||||
$this->untrack_file($path);
|
$this->untrack_file($path);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename a file or a directory.
|
* Rename a file or a directory.
|
||||||
@ -165,18 +151,11 @@ class storage
|
|||||||
* When file/directory cannot be renamed
|
* When file/directory cannot be renamed
|
||||||
*/
|
*/
|
||||||
public function rename($path_orig, $path_dest)
|
public function rename($path_orig, $path_dest)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
$this->get_adapter()->rename($path_orig, $path_dest);
|
$this->get_adapter()->rename($path_orig, $path_dest);
|
||||||
$this->untrack_file($path_orig);
|
$this->untrack_file($path_orig);
|
||||||
$this->track_file($path_dest);
|
$this->track_file($path_dest);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies a file.
|
* Copies a file.
|
||||||
@ -188,17 +167,10 @@ class storage
|
|||||||
* When the file cannot be copied
|
* When the file cannot be copied
|
||||||
*/
|
*/
|
||||||
public function copy($path_orig, $path_dest)
|
public function copy($path_orig, $path_dest)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
$this->get_adapter()->copy($path_orig, $path_dest);
|
$this->get_adapter()->copy($path_orig, $path_dest);
|
||||||
$this->track_file($path_dest);
|
$this->track_file($path_dest);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a file as a stream.
|
* Reads a file as a stream.
|
||||||
@ -231,6 +203,7 @@ class storage
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a new file using a stream.
|
* Writes a new file using a stream.
|
||||||
|
* You have to track file after use this method
|
||||||
*
|
*
|
||||||
* @param string $path The target file
|
* @param string $path The target file
|
||||||
* @param resource $resource The resource
|
* @param resource $resource The resource
|
||||||
@ -244,7 +217,6 @@ class storage
|
|||||||
if ($adapter instanceof stream_interface)
|
if ($adapter instanceof stream_interface)
|
||||||
{
|
{
|
||||||
$adapter->write_stream($path, $resource);
|
$adapter->write_stream($path, $resource);
|
||||||
$this->track_file($path); // Not sure if here, or after close the file
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -337,9 +309,9 @@ class storage
|
|||||||
FROM ' . $this->storage_table . "
|
FROM ' . $this->storage_table . "
|
||||||
WHERE storage = '" . $this->get_name() . "'";
|
WHERE storage = '" . $this->get_name() . "'";
|
||||||
$result = $this->db->sql_query($sql);
|
$result = $this->db->sql_query($sql);
|
||||||
$row = $this->db->sql_fetchrow($result);
|
$total = (int) $this->db->sql_fetchfield('total');
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
return $row['total'];
|
return $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user