Commit 18ed37e4 authored by mickadoo's avatar mickadoo

52: Use book slug as lock file name instead of app level one

parent 3873a10a
......@@ -25,21 +25,22 @@ class PublishController extends Controller {
/**
* @Route("/admin/publish{identifier}" , requirements={"identifier": ".*"})
*
* @param Request $request
* @param $identifier
*
* @return Response
*/
public function PublishAction(Request $request, $identifier) {
public function PublishAction($identifier) {
$lockFileHandler = $this->get('lockfile_handler');
if ($lockFileHandler->exists('publishing')) {
$this->publisher = $this->get('publisher');
$bookSlug = Library::parseIdentifier($identifier)['bookSlug'];
if ($lockFileHandler->exists($bookSlug)) {
$err = 'Publishing is already in process, please try again later';
throw new ConflictHttpException($err);
}
$lockFileHandler->create('publishing');
$lockFileHandler->create($bookSlug);
$this->publisher = $this->get('publisher');
$bookSlug = Library::parseIdentifier($identifier)['bookSlug'];
if ($bookSlug) {
$this->publishSuccess = $this->publisher->publish($identifier);
}
......@@ -51,10 +52,11 @@ class PublishController extends Controller {
. "to really slow down the server. If you want to publish all books "
. "you can run 'docs:publish' from the command line interface.");
}
$content['identifier'] = trim($identifier, "/");
$content['messages'] = $this->publisher->getMessages();
$lockFileHandler->release('publishing');
$lockFileHandler->release($bookSlug);
return $this->render('AppBundle:Publish:publish.html.twig', $content);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment