Skip to content

Commit bee2e12

Browse files
committed
Fixed #788 // Redundant directory name for Sqlite
1 parent d2c9d91 commit bee2e12

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

lib/Phpfastcache/Drivers/Sqlite/Driver.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ class Driver implements ExtendedCacheItemPoolInterface, AggregatablePoolInterfac
3434
{
3535
use DriverBaseTrait, IOHelperTrait;
3636

37-
/**
38-
*
39-
*/
40-
protected const FILE_DIR = 'sqlite';
4137
/**
4238
*
4339
*/
@@ -77,7 +73,7 @@ public function driverCheck(): bool
7773
*/
7874
public function getSqliteDir(): string
7975
{
80-
return $this->SqliteDir ?: $this->getPath() . DIRECTORY_SEPARATOR . self::FILE_DIR;
76+
return $this->SqliteDir ?: $this->getPath();
8177
}
8278

8379
/**
@@ -97,13 +93,13 @@ protected function driverConnect(): bool
9793
if (!file_exists($this->getSqliteDir()) && !@mkdir($this->getSqliteDir(), $this->getDefaultChmod(), true)) {
9894
throw new PhpfastcacheIOException(sprintf('Sqlite cannot write in "%s", aborting...', $this->getPath()));
9995
}
100-
if (!file_exists($this->getPath() . '/' . self::FILE_DIR)) {
101-
if (!mkdir($this->getPath() . '/' . self::FILE_DIR, $this->getDefaultChmod(), true)
96+
if (!file_exists($this->getPath())) {
97+
if (!mkdir($this->getPath(), $this->getDefaultChmod(), true)
10298
) {
10399
$this->fallback = true;
104100
}
105101
}
106-
$this->SqliteDir = $this->getPath() . '/' . self::FILE_DIR;
102+
$this->SqliteDir = $this->getPath();
107103

108104
return true;
109105
}

lib/Phpfastcache/Helper/TestHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,4 +482,4 @@ public function printPassText(string $string): self
482482

483483
return $this;
484484
}
485-
}
485+
}

tests/Sqlite.test.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/**
4+
* @author Khoa Bui (khoaofgod) <[email protected]> https://www.phpfastcache.com
5+
* @author Georges.L (Geolim4) <[email protected]>
6+
*/
7+
8+
use Phpfastcache\CacheManager;
9+
use Phpfastcache\Config\ConfigurationOption;
10+
use Phpfastcache\Helper\TestHelper;
11+
12+
chdir(__DIR__);
13+
require_once __DIR__ . '/../vendor/autoload.php';
14+
$testHelper = new TestHelper('Sqlite');
15+
CacheManager::setDefaultConfig(new ConfigurationOption(['path' => __DIR__ . '/../cache']));
16+
17+
$cacheInstance = CacheManager::getInstance('Sqlite');
18+
19+
$testHelper->runCRUDTests($cacheInstance);
20+
21+
$testHelper->terminateTest();

0 commit comments

Comments
 (0)