Update Kirby to 3.7.4
This commit is contained in:
2
kirby/src/Filesystem/Asset.php
Executable file → Normal file
2
kirby/src/Filesystem/Asset.php
Executable file → Normal file
@@ -38,7 +38,7 @@ class Asset
|
||||
$this->setProperties([
|
||||
'path' => dirname($path),
|
||||
'root' => $this->kirby()->root('index') . '/' . $path,
|
||||
'url' => $this->kirby()->url('index') . '/' . $path
|
||||
'url' => $this->kirby()->url('base') . '/' . $path
|
||||
]);
|
||||
}
|
||||
|
||||
|
8
kirby/src/Filesystem/Dir.php
Executable file → Normal file
8
kirby/src/Filesystem/Dir.php
Executable file → Normal file
@@ -537,7 +537,7 @@ class Dir
|
||||
}
|
||||
|
||||
if (is_link($dir) === true) {
|
||||
return unlink($dir);
|
||||
return F::unlink($dir);
|
||||
}
|
||||
|
||||
foreach (scandir($dir) as $childName) {
|
||||
@@ -547,12 +547,10 @@ class Dir
|
||||
|
||||
$child = $dir . '/' . $childName;
|
||||
|
||||
if (is_link($child) === true) {
|
||||
unlink($child);
|
||||
} elseif (is_dir($child) === true) {
|
||||
if (is_dir($child) === true && is_link($child) === false) {
|
||||
static::remove($child);
|
||||
} else {
|
||||
F::remove($child);
|
||||
F::unlink($child);
|
||||
}
|
||||
}
|
||||
|
||||
|
30
kirby/src/Filesystem/F.php
Executable file → Normal file
30
kirby/src/Filesystem/F.php
Executable file → Normal file
@@ -3,6 +3,7 @@
|
||||
namespace Kirby\Filesystem;
|
||||
|
||||
use Exception;
|
||||
use Kirby\Cms\Helpers;
|
||||
use Kirby\Toolkit\I18n;
|
||||
use Kirby\Toolkit\Str;
|
||||
use Throwable;
|
||||
@@ -727,12 +728,11 @@ class F
|
||||
}
|
||||
|
||||
$file = realpath($file);
|
||||
|
||||
if (file_exists($file) === false) {
|
||||
if (is_string($file) === false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return unlink($file);
|
||||
return static::unlink($file);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -846,6 +846,30 @@ class F
|
||||
return static::$types[$type] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that a file or link is deleted (with race condition handling)
|
||||
* @since 3.7.4
|
||||
*/
|
||||
public static function unlink(string $file): bool
|
||||
{
|
||||
return Helpers::handleErrors(
|
||||
fn (): bool => unlink($file),
|
||||
function (&$override, int $errno, string $errstr): bool {
|
||||
// if the file or link was already deleted (race condition),
|
||||
// consider it a success
|
||||
if (Str::endsWith($errstr, 'No such file or directory') === true) {
|
||||
$override = true;
|
||||
|
||||
// drop the warning
|
||||
return true;
|
||||
}
|
||||
|
||||
// handle every other warning normally
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unzips a zip file
|
||||
*
|
||||
|
0
kirby/src/Filesystem/File.php
Executable file → Normal file
0
kirby/src/Filesystem/File.php
Executable file → Normal file
0
kirby/src/Filesystem/Filename.php
Executable file → Normal file
0
kirby/src/Filesystem/Filename.php
Executable file → Normal file
0
kirby/src/Filesystem/IsFile.php
Executable file → Normal file
0
kirby/src/Filesystem/IsFile.php
Executable file → Normal file
8
kirby/src/Filesystem/Mime.php
Executable file → Normal file
8
kirby/src/Filesystem/Mime.php
Executable file → Normal file
@@ -61,6 +61,7 @@ class Mime
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'mif' => 'application/vnd.mif',
|
||||
'mjs' => 'text/javascript',
|
||||
'mov' => 'video/quicktime',
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'mp2' => 'audio/mpeg',
|
||||
@@ -133,13 +134,20 @@ class Mime
|
||||
'text/plain' => [
|
||||
'css' => 'text/css',
|
||||
'json' => 'application/json',
|
||||
'mjs' => 'text/javascript',
|
||||
'svg' => ['Kirby\Filesystem\Mime', 'fromSvg'],
|
||||
],
|
||||
'text/x-asm' => [
|
||||
'css' => 'text/css'
|
||||
],
|
||||
'text/x-java' => [
|
||||
'mjs' => 'text/javascript',
|
||||
],
|
||||
'image/svg' => [
|
||||
'svg' => 'image/svg+xml'
|
||||
],
|
||||
'application/octet-stream' => [
|
||||
'mjs' => 'text/javascript'
|
||||
]
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user