Skip to content

Commit 96819b7

Browse files
committed
Images: Updated image timestamp upon file change
For #4354
1 parent 18ee80a commit 96819b7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

app/Uploads/ImageRepo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public function updateImageFile(Image $image, UploadedFile $file): void
177177

178178
$image->refresh();
179179
$image->updated_by = user()->id;
180+
$image->touch();
180181
$image->save();
181182
$this->imageService->replaceExistingFromUpload($image->path, $image->type, $file);
182183
$this->loadThumbs($image, true);

tests/Uploads/ImageTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,18 @@ public function test_image_file_update()
104104
$this->assertFileEquals($this->files->testFilePath('test-image.png'), public_path($relPath));
105105

106106
$imageId = $imgDetails['response']->id;
107+
$image = Image::findOrFail($imageId);
108+
$image->updated_at = now()->subMonth();
109+
$image->save();
110+
107111
$this->call('PUT', "/images/{$imageId}/file", [], [], ['file' => $newUpload])
108112
->assertOk();
109113

110114
$this->assertFileEquals($this->files->testFilePath('compressed.png'), public_path($relPath));
111115

116+
$image->refresh();
117+
$this->assertTrue($image->updated_at->gt(now()->subMinute()));
118+
112119
$this->files->deleteAtRelativePath($relPath);
113120
}
114121

0 commit comments

Comments
 (0)