mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Thumbnails: Added OOM handling and regen endpoint
- Added some level of app out-of-memory handling so we can show a proper error message upon OOM events. - Added endpoint and image-manager button/action for regenerating thumbnails for an image so they can be re-created upon failure.
This commit is contained in:
@ -8,6 +8,7 @@ use BookStack\Http\Controller;
|
||||
use BookStack\Uploads\Image;
|
||||
use BookStack\Uploads\ImageRepo;
|
||||
use BookStack\Uploads\ImageService;
|
||||
use BookStack\Util\OutOfMemoryHandler;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
@ -121,6 +122,24 @@ class ImageController extends Controller
|
||||
return response('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild the thumbnails for the given image.
|
||||
*/
|
||||
public function rebuildThumbnails(string $id)
|
||||
{
|
||||
$image = $this->imageRepo->getById($id);
|
||||
$this->checkImagePermission($image);
|
||||
$this->checkOwnablePermission('image-update', $image);
|
||||
|
||||
new OutOfMemoryHandler(function () {
|
||||
return $this->jsonError(trans('errors.image_thumbnail_memory_limit'));
|
||||
});
|
||||
|
||||
$this->imageRepo->loadThumbs($image, true);
|
||||
|
||||
return response(trans('components.image_rebuild_thumbs_success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check related page permission and ensure type is drawio or gallery.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user