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 rotation changed then update the previews
|
||||||
if ($raw['Orientation'] ?? false) {
|
if ($raw['Orientation'] ?? false) {
|
||||||
$this->deletePreviews($file);
|
$this->refreshPreviews($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->info($id, true);
|
return $this->info($id, true);
|
||||||
|
@ -474,8 +474,10 @@ class ImageController extends GenericApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidate previews for a file.
|
* 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 {
|
try {
|
||||||
$previewRoot = new \OC\Preview\Storage\Root(
|
$previewRoot = new \OC\Preview\Storage\Root(
|
||||||
|
@ -483,8 +485,13 @@ class ImageController extends GenericApiController
|
||||||
\OC::$server->get(\OC\SystemConfig::class),
|
\OC::$server->get(\OC\SystemConfig::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Delete the preview folder
|
||||||
$fileId = (string) $file->getId();
|
$fileId = (string) $file->getId();
|
||||||
$previewRoot->getFolder($fileId)->delete();
|
$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) {
|
} catch (\Exception $e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,6 +322,7 @@ export default defineComponent({
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.refs.editOrientation?.reset();
|
||||||
this.processing = false;
|
this.processing = false;
|
||||||
this.close();
|
this.close();
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,9 @@ export default defineComponent({
|
||||||
return `${this.transform1} rotate(${d * 360 * f}deg)`;
|
return `${this.transform1} rotate(${d * 360 * f}deg)`;
|
||||||
},
|
},
|
||||||
|
|
||||||
transform1() {
|
transform1(): string | null {
|
||||||
|
if (this.disabled) return null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1 = Horizontal (normal)
|
* 1 = Horizontal (normal)
|
||||||
* 2 = Mirror horizontal
|
* 2 = Mirror horizontal
|
||||||
|
@ -121,10 +123,18 @@ export default defineComponent({
|
||||||
case 8:
|
case 8:
|
||||||
return 'rotate(270deg)';
|
return 'rotate(270deg)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
/** Reset state to initial */
|
||||||
|
reset() {
|
||||||
|
this.state = 1;
|
||||||
|
this.spins = 0;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get target orientation state for a photo.
|
* Get target orientation state for a photo.
|
||||||
* If no change is needed, return null.
|
* If no change is needed, return null.
|
||||||
|
|
Loading…
Reference in New Issue