mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-31 17:19:59 +09:00
Do not use safe_overwrite if target directory is not writable
This commit is contained in:
parent
3d8b7755ee
commit
55547c56e4
1 changed files with 15 additions and 4 deletions
|
|
@ -240,11 +240,16 @@ class Storage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$safe_overwrite && strncasecmp($mode, 'a', 1))
|
if (self::$safe_overwrite && strncasecmp($mode, 'a', 1) && @is_writable($destination_dir))
|
||||||
{
|
{
|
||||||
|
$use_atomic_rename = true;
|
||||||
$original_filename = $filename;
|
$original_filename = $filename;
|
||||||
$filename = $filename . '.tmp.' . microtime(true);
|
$filename = $filename . '.tmp.' . microtime(true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$use_atomic_rename = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($fp = @fopen($filename, $mode))
|
if ($fp = @fopen($filename, $mode))
|
||||||
{
|
{
|
||||||
|
|
@ -275,7 +280,7 @@ class Storage
|
||||||
|
|
||||||
@chmod($filename, ($perms === null ? (0666 & ~self::getUmask()) : $perms));
|
@chmod($filename, ($perms === null ? (0666 & ~self::getUmask()) : $perms));
|
||||||
|
|
||||||
if (self::$safe_overwrite && strncasecmp($mode, 'a', 1))
|
if ($use_atomic_rename)
|
||||||
{
|
{
|
||||||
$rename_success = @rename($filename, $original_filename);
|
$rename_success = @rename($filename, $original_filename);
|
||||||
if (!$rename_success)
|
if (!$rename_success)
|
||||||
|
|
@ -350,14 +355,20 @@ class Storage
|
||||||
}
|
}
|
||||||
elseif (self::isDirectory($destination))
|
elseif (self::isDirectory($destination))
|
||||||
{
|
{
|
||||||
|
$destination_dir = $destination;
|
||||||
$destination = $destination . '/' . basename($source);
|
$destination = $destination . '/' . basename($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$safe_overwrite)
|
if (self::$safe_overwrite && @is_writable($destination_dir))
|
||||||
{
|
{
|
||||||
|
$use_atomic_rename = true;
|
||||||
$original_destination = $destination;
|
$original_destination = $destination;
|
||||||
$destination = $destination . '.tmp.' . microtime(true);
|
$destination = $destination . '.tmp.' . microtime(true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$use_atomic_rename = false;
|
||||||
|
}
|
||||||
|
|
||||||
$copy_success = @copy($source, $destination);
|
$copy_success = @copy($source, $destination);
|
||||||
if (!$copy_success)
|
if (!$copy_success)
|
||||||
|
|
@ -382,7 +393,7 @@ class Storage
|
||||||
@chmod($destination, $destination_perms);
|
@chmod($destination, $destination_perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$safe_overwrite)
|
if ($use_atomic_rename)
|
||||||
{
|
{
|
||||||
$rename_success = @rename($destination, $original_destination);
|
$rename_success = @rename($destination, $original_destination);
|
||||||
if (!$rename_success)
|
if (!$rename_success)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue