Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqliteEngine can create index storage parent directory if needed #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
SqliteEngine can create index storage parent directory if needed
This avoids a fatal error on initial run, if using an unversioned storage area that is hard to set up initialised (but still allows for custom organisation of that storage area)
  • Loading branch information
brendanpetty committed Nov 5, 2023
commit 75ad4adbbe93c508e5f2c89aeef10b8534f7bda3
4 changes: 4 additions & 0 deletions src/Engines/SqliteEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public function createIndex($indexName)

$this->flushIndex($indexName);

if(!file_exists($this->config['storage'])) { // create the parent folder, if doesn't exist
mkdir($this->config['storage'], 0700, true);
}

$this->index = new PDO('sqlite:' . $this->config['storage'] . $indexName);
$this->index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

Expand Down