image: fix preview race after edit
Signed-off-by: Varun Patil <radialapps@gmail.com>pulsejet/aio-hw-docs
parent
7eb232c10f
commit
379184247f
|
@ -271,7 +271,7 @@ class ImageController extends GenericApiController
|
|||
|
||||
// If rotation changed then update the previews
|
||||
if ($raw['Orientation'] ?? false) {
|
||||
$this->deletePreviews($file);
|
||||
$this->refreshPreviews($file);
|
||||
}
|
||||
|
||||
return $this->info($id, true);
|
||||
|
@ -474,8 +474,10 @@ class ImageController extends GenericApiController
|
|||
|
||||
/**
|
||||
* Invalidate previews for a file.
|
||||
*
|
||||
* @param \OCP\Files\File $file File to invalidate previews for
|
||||
*/
|
||||
private function deletePreviews(\OCP\Files\File $file): void
|
||||
private function refreshPreviews(\OCP\Files\File $file): void
|
||||
{
|
||||
try {
|
||||
$previewRoot = new \OC\Preview\Storage\Root(
|
||||
|
@ -483,8 +485,13 @@ class ImageController extends GenericApiController
|
|||
\OC::$server->get(\OC\SystemConfig::class),
|
||||
);
|
||||
|
||||
// Delete the preview folder
|
||||
$fileId = (string) $file->getId();
|
||||
$previewRoot->getFolder($fileId)->delete();
|
||||
|
||||
// Get the preview to regenerate
|
||||
$previewManager = \OC::$server->get(\OCP\IPreview::class);
|
||||
$previewManager->getPreview($file, 32, 32, true, \OCP\IPreview::MODE_FILL);
|
||||
} catch (\Exception $e) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -322,6 +322,7 @@ export default defineComponent({
|
|||
// nothing to do
|
||||
}
|
||||
|
||||
this.refs.editOrientation?.reset();
|
||||
this.processing = false;
|
||||
this.close();
|
||||
|
||||
|
|
|
@ -87,7 +87,9 @@ export default defineComponent({
|
|||
return `${this.transform1} rotate(${d * 360 * f}deg)`;
|
||||
},
|
||||
|
||||
transform1() {
|
||||
transform1(): string | null {
|
||||
if (this.disabled) return null;
|
||||
|
||||
/**
|
||||
* 1 = Horizontal (normal)
|
||||
* 2 = Mirror horizontal
|
||||
|
@ -121,10 +123,18 @@ export default defineComponent({
|
|||
case 8:
|
||||
return 'rotate(270deg)';
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
/** Reset state to initial */
|
||||
reset() {
|
||||
this.state = 1;
|
||||
this.spins = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get target orientation state for a photo.
|
||||
* If no change is needed, return null.
|
||||
|
|
Loading…
Reference in New Issue