This commit is contained in:
Dennis Eichhorn 2023-08-28 22:06:35 +00:00
parent 0989aaa5e7
commit 1e74be0e78
2 changed files with 11 additions and 10 deletions

View File

@ -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);

View File

@ -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';