Storage: throw StorageException on errors
This commit is contained in:
parent
7df3f117ac
commit
6e85a18678
|
@ -58,13 +58,13 @@ class Filesystem implements IStorage
|
||||||
if (!is_dir($path)) {
|
if (!is_dir($path)) {
|
||||||
if (!mkdir($path, 0770, true)) {
|
if (!mkdir($path, 0770, true)) {
|
||||||
Logger::log("Failed to create dirs {$path}");
|
Logger::log("Failed to create dirs {$path}");
|
||||||
echo L10n::t("Filesystem storage failed to create '%s'. Check you write permissions.", $path);
|
throw new StorageException(L10n::t("Filesystem storage failed to create '%s'. Check you write permissions.", $path));
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$base = self::getBasePath();
|
$base = self::getBasePath();
|
||||||
|
|
||||||
while ($path !== $base) {
|
while ($path !== $base) {
|
||||||
if (!is_file($path . "/index.html")) {
|
if (!is_file($path . "/index.html")) {
|
||||||
file_put_contents($path . "/index.html", "");
|
file_put_contents($path . "/index.html", "");
|
||||||
|
@ -98,7 +98,7 @@ class Filesystem implements IStorage
|
||||||
$r = file_put_contents($file, $data);
|
$r = file_put_contents($file, $data);
|
||||||
if ($r === FALSE) {
|
if ($r === FALSE) {
|
||||||
Logger::log("Failed to write data to {$file}");
|
Logger::log("Failed to write data to {$file}");
|
||||||
echo L10n::t("Filesystem storage failed to save data to '%s'. Check your write permissions", $file);
|
throw new StorageException(L10n::t("Filesystem storage failed to save data to '%s'. Check your write permissions", $file));
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
return $ref;
|
return $ref;
|
||||||
|
@ -108,7 +108,7 @@ class Filesystem implements IStorage
|
||||||
{
|
{
|
||||||
$file = self::pathForRef($ref);
|
$file = self::pathForRef($ref);
|
||||||
// return true if file doesn't exists. we want to delete it: success with zero work!
|
// return true if file doesn't exists. we want to delete it: success with zero work!
|
||||||
if (!is_file($file)) {
|
if (!is_file($file)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return unlink($file);
|
return unlink($file);
|
||||||
|
|
15
src/Model/Storage/StorageException.php
Normal file
15
src/Model/Storage/StorageException.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @file src/Model/Storage/StorageException.php
|
||||||
|
* @brief Storage backend system
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Friendica\Model\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Storage Exception
|
||||||
|
*/
|
||||||
|
class StorageException extends \Exception
|
||||||
|
{
|
||||||
|
}
|
Loading…
Reference in a new issue