From 1e74be0e7815db179d076841c823c7fa847aff45 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 28 Aug 2023 22:06:35 +0000 Subject: [PATCH] update --- Controller/ApiController.php | 17 ++++++++++------- tests/Autoloader.php | 4 +--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 78e8a7b..8adeadb 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -191,11 +191,7 @@ final class ApiController extends Controller $resource->path = $request->getDataString('path') ?? ''; // @todo: check if user is part of organization below AND has free resources to add!!! - $resource->organization = new NullAccount( - !$request->hasData('organization') - ? 1 - : (int) ($request->getData('organization')) - ); + $resource->organization = new NullAccount($request->getDataInt('organization') ?? 1); return $resource; } @@ -514,9 +510,16 @@ final class ApiController extends Controller $hasDifferentHash = $md5Old !== $md5New; - // @todo: check if old path exists and if not, don't calculate a diff - $difference = 0; + + // Is new file -> always different -> no content inspection required + if ($hasDifferentHash && !\is_file($oldPath)) { + $difference = 1; + + $hasDifferentHash = false; + } + + // Different file hash -> content inspection required if ($hasDifferentHash) { if (\in_array($extension, self::TEXT_RENDERABLE)) { $contentOld = \Modules\Media\Controller\ApiController::loadFileContent($oldPath, $extension); diff --git a/tests/Autoloader.php b/tests/Autoloader.php index 80a0a1e..d2d0080 100755 --- a/tests/Autoloader.php +++ b/tests/Autoloader.php @@ -71,14 +71,12 @@ final class Autoloader * * @return void * - * @throws AutoloadException Throws this exception if the class to autoload doesn't exist. This could also be related to a wrong namespace/file path correlation. - * * @since 1.0.0 */ public static function defaultAutoloader(string $class) : void { $class = \ltrim($class, '\\'); - $class = \str_replace(['_', '\\'], '/', $class); + $class = \strtr($class, '_\\', '//'); foreach (self::$paths as $path) { $file = $path . $class . '.php';