]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6716 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 8 Feb 2024 09:08:18 +0000 (10:08 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 8 Feb 2024 09:08:18 +0000 (10:08 +0100)
app/Http/Controllers/Admin/Operations/Files/UploadOperation.php
app/Models/File.php

index dff622e2c4a0f3574d1f489b6a5fc011f585a7e8..d6cc9e4c2042fdb8b4bbeb2e5cf61d29f571542c 100644 (file)
@@ -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' => '<b>' . $j . '</b>']))->flash();
index fcdd05ec8169e056dec8fc0b4c75cd1b61dd3e05..8f03cad316d5349280aac8233134a74db810de61 100644 (file)
@@ -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()