From: Vincent Vanwaelscappel Date: Thu, 8 Feb 2024 09:08:18 +0000 (+0100) Subject: wait #6716 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=626cdb1f9416779f657bdc83a022c8b0aaf2c26f;p=fluidbook-toolbox.git wait #6716 @0.5 --- diff --git a/app/Http/Controllers/Admin/Operations/Files/UploadOperation.php b/app/Http/Controllers/Admin/Operations/Files/UploadOperation.php index dff622e2c..d6cc9e4c2 100644 --- a/app/Http/Controllers/Admin/Operations/Files/UploadOperation.php +++ b/app/Http/Controllers/Admin/Operations/Files/UploadOperation.php @@ -66,7 +66,7 @@ trait UploadOperation $actions = []; foreach ($paths as $path) { $spl = new \SplFileInfo($path); - $actions[$spl->getFilename()] = backpack_url('/file/' . File::hash($path) . '/' . $spl->getFilename()); + $actions[$spl->getFilename()] = backpack_url('/file/' . File::hash($path, $spl->getSize()) . '/' . $spl->getFilename()); } Slack::send($destChannel, $subject, '', $actions); Alert::success(__(':nb fichiers chargés', ['nb' => '' . $j . '']))->flash(); diff --git a/app/Models/File.php b/app/Models/File.php index fcdd05ec8..8f03cad31 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -34,6 +34,8 @@ class File extends ToolboxModel protected $_enableClone = false; protected $_enableCreation = false; + protected $_enableRevisions = false; + protected $primaryKey = 'hash'; public $incrementing = false; protected $keyType = 'string'; @@ -119,7 +121,8 @@ class File extends ToolboxModel $date = new \DateTime(); $date->setTimestamp($mtime); - $hash = self::hash($pathname); + $size = $file->getSize(); + $hash = self::hash($pathname, $size); $res[$hash] = [ 'path' => $pathname, @@ -127,7 +130,7 @@ class File extends ToolboxModel 'ext' => mb_strtolower($file->getExtension()), 'created_at' => $date, 'updated_at' => $date, - 'size' => $file->getSize(), + 'size' => $size, 'from' => $from, 'to' => $to, 'owner' => $id, @@ -187,9 +190,9 @@ class File extends ToolboxModel return $dest; } - public static function hash($pathname) + public static function hash($pathname, $size) { - return sha1('!!//' . trim(str_replace(self::$basePath, '', $pathname), '/') . '||--'); + return sha1('!!//' . trim(str_replace(self::$basePath, '', $pathname), '/') . '||--' . $size . '-**'); } public function showPrimaryColumn()