Images: Updated image timestamp upon file change

For #4354
This commit is contained in:
Dan Brown 2023-07-05 11:28:03 +01:00
parent 18ee80a743
commit 96819b7bd9
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 8 additions and 0 deletions

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

View 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);
}