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) {
$sUser = $sPassword = '';
$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 {
$sDsn = $sDsnType . ':' . \preg_replace('/^[a-z]+:/', '', $sDsn);
}

View file

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

View file

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

View file

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