public function actionRebuild() {
        $module = \jacmoe\mdpages\Module::getInstance();

        if(!is_dir(Yii::getAlias($module->pages_directory))) {
            $this->stderr("Execution terminated: the repository to update does not exist - please run init first.\n", Console::FG_RED);
            return self::EXIT_CODE_ERROR;
        }

        if (!$this->acquireMutex()) {
            $this->stderr("Execution terminated: command is already running.\n", Console::FG_RED);
            return self::EXIT_CODE_ERROR;
        }

        $files = FileHelper::findFiles(Yii::getAlias('@pages'), [
            'only' => ['*' . $module->page_extension],
        ]);

        $this->updateDB($files, false);

        $this->releaseMutex();
        return self::EXIT_CODE_NORMAL;
    }