]> BookStack Code Mirror - bookstack/commitdiff
Images: Updated image timestamp upon file change
authorDan Brown <redacted>
Wed, 5 Jul 2023 10:28:03 +0000 (11:28 +0100)
committerDan Brown <redacted>
Wed, 5 Jul 2023 10:28:03 +0000 (11:28 +0100)
For #4354

app/Uploads/ImageRepo.php
tests/Uploads/ImageTest.php

index cdd5485acc127845670792f2128ac816a989e231..5507933f3fafbbb8e9025a52eb0674ce12b4c8ca 100644 (file)
@@ -177,6 +177,7 @@ class ImageRepo
 
         $image->refresh();
         $image->updated_by = user()->id;
+        $image->touch();
         $image->save();
         $this->imageService->replaceExistingFromUpload($image->path, $image->type, $file);
         $this->loadThumbs($image, true);
index f9cc419a4fb1a1420e6a4f618825f2d3af7e6820..a9684eef72a9e52a55897571227ddf680f11daae 100644 (file)
@@ -104,11 +104,18 @@ class ImageTest extends TestCase
         $this->assertFileEquals($this->files->testFilePath('test-image.png'), public_path($relPath));
 
         $imageId = $imgDetails['response']->id;
+        $image = Image::findOrFail($imageId);
+        $image->updated_at = now()->subMonth();
+        $image->save();
+
         $this->call('PUT', "/images/{$imageId}/file", [], [], ['file' => $newUpload])
             ->assertOk();
 
         $this->assertFileEquals($this->files->testFilePath('compressed.png'), public_path($relPath));
 
+        $image->refresh();
+        $this->assertTrue($image->updated_at->gt(now()->subMinute()));
+
         $this->files->deleteAtRelativePath($relPath);
     }