FileStorage add ROOT option

This commit is contained in:
the-djmaze 2022-05-11 13:32:39 +02:00
parent bf276510ba
commit aa69772127
4 changed files with 15 additions and 3 deletions

View file

@ -255,6 +255,14 @@ class Actions
if ('sqlite' === $sDsnType) { if ('sqlite' === $sDsnType) {
$sUser = $sPassword = ''; $sUser = $sPassword = '';
$sDsn = 'sqlite:' . APP_PRIVATE_DATA . 'AddressBook.sqlite'; $sDsn = 'sqlite:' . APP_PRIVATE_DATA . 'AddressBook.sqlite';
/*
// TODO: use local db?
$homedir = $this->StorageProvider()->GenerateFilePath(
$oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::ROOT
);
$sDsn = 'sqlite:' . $homedir . '/AddressBook.sqlite';
*/
} else { } else {
$sDsn = $sDsnType . ':' . \preg_replace('/^[a-z]+:/', '', $sDsn); $sDsn = $sDsnType . ':' . \preg_replace('/^[a-z]+:/', '', $sDsn);
} }

View file

@ -18,10 +18,10 @@ trait Pgp
return null; return null;
} }
$homedir = \dirname($this->StorageProvider()->GenerateFilePath( $homedir = $this->StorageProvider()->GenerateFilePath(
$oAccount, $oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::PGP \RainLoop\Providers\Storage\Enumerations\StorageType::ROOT
)) . '/.gnupg'; ) . '/.gnupg';
if (!\is_dir($homedir)) { if (!\is_dir($homedir)) {
\mkdir($homedir, 0700, true); \mkdir($homedir, 0700, true);

View file

@ -10,4 +10,5 @@ class StorageType
const SIGN_ME = 4; const SIGN_ME = 4;
const SESSION = 5; const SESSION = 5;
const PGP = 6; const PGP = 6;
const ROOT = 7;
} }

View file

@ -112,6 +112,8 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
$sSubFolder = '.sessions'; $sSubFolder = '.sessions';
} else if (StorageType::PGP === $iStorageType) { } else if (StorageType::PGP === $iStorageType) {
$sSubFolder = '.pgp'; $sSubFolder = '.pgp';
} else if (StorageType::ROOT === $iStorageType) {
$sSubFolder = '';
} }
} }
@ -125,6 +127,7 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
case StorageType::SESSION: case StorageType::SESSION:
case StorageType::CONFIG: case StorageType::CONFIG:
case StorageType::PGP: case StorageType::PGP:
case StorageType::ROOT:
if (empty($sEmail)) { if (empty($sEmail)) {
return ''; return '';
} }