mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Small StorageType change
This commit is contained in:
parent
2559c09b23
commit
ab748aab99
5 changed files with 70 additions and 58 deletions
|
|
@ -12,7 +12,7 @@ class NextcloudStorage extends \RainLoop\Providers\Storage\FileStorage
|
||||||
$sDataPath = parent::GenerateFilePath($mAccount, $iStorageType, $bMkDir);
|
$sDataPath = parent::GenerateFilePath($mAccount, $iStorageType, $bMkDir);
|
||||||
if (StorageType::CONFIG === $iStorageType) {
|
if (StorageType::CONFIG === $iStorageType) {
|
||||||
$sUID = \OC::$server->getUserSession()->getUser()->getUID();
|
$sUID = \OC::$server->getUserSession()->getUser()->getUID();
|
||||||
$sDataPath .= "/.config/{$sUID}/";
|
$sDataPath .= ".config/{$sUID}/";
|
||||||
if ($bMkDir && !\is_dir($sDataPath) && !\mkdir($sDataPath, 0700, true)) {
|
if ($bMkDir && !\is_dir($sDataPath) && !\mkdir($sDataPath, 0700, true)) {
|
||||||
throw new \RainLoop\Exceptions\Exception('Can\'t make storage directory "'.$sDataPath.'"');
|
throw new \RainLoop\Exceptions\Exception('Can\'t make storage directory "'.$sDataPath.'"');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -306,4 +306,11 @@ abstract class Account implements \JsonSerializable
|
||||||
return $bResult;
|
return $bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Stores settings in AdditionalAccount else MainAccount
|
||||||
|
public function settingsLocal() : \RainLoop\Settings
|
||||||
|
{
|
||||||
|
return \RainLoop\Api::Actions()->SettingsProvider(true)->Load($this);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,4 +63,11 @@ class MainAccount extends Account
|
||||||
{
|
{
|
||||||
$this->sCryptKey = new SensitiveString($sKey);
|
$this->sCryptKey = new SensitiveString($sKey);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
// Stores settings in MainAccount
|
||||||
|
public function settings() : \RainLoop\Settings
|
||||||
|
{
|
||||||
|
return \RainLoop\Api::Actions()->SettingsProvider()->Load($this);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,10 @@ enum StorageType: int {
|
||||||
*/
|
*/
|
||||||
abstract class StorageType
|
abstract class StorageType
|
||||||
{
|
{
|
||||||
const USER = 1;
|
const CONFIG = 1;
|
||||||
const CONFIG = 2;
|
const NOBODY = 2;
|
||||||
const NOBODY = 3;
|
const SIGN_ME = 3;
|
||||||
const SIGN_ME = 4;
|
const SESSION = 4;
|
||||||
const SESSION = 5;
|
const PGP = 5;
|
||||||
const PGP = 6;
|
const ROOT = 6;
|
||||||
const ROOT = 7;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,10 +90,11 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
||||||
*/
|
*/
|
||||||
public function GenerateFilePath($mAccount, int $iStorageType, bool $bMkDir = false) : string
|
public function GenerateFilePath($mAccount, int $iStorageType, bool $bMkDir = false) : string
|
||||||
{
|
{
|
||||||
$sEmail = $sSubFolder = '';
|
$sEmail = $sSubFolder = $sFilePath = '';
|
||||||
if (null === $mAccount) {
|
if (null === $mAccount || StorageType::NOBODY === $iStorageType) {
|
||||||
$iStorageType = StorageType::NOBODY;
|
$sFilePath = $this->sDataPath.'/__nobody__/';
|
||||||
} else if ($mAccount instanceof \RainLoop\Model\MainAccount) {
|
} else {
|
||||||
|
if ($mAccount instanceof \RainLoop\Model\MainAccount) {
|
||||||
$sEmail = $mAccount->Email();
|
$sEmail = $mAccount->Email();
|
||||||
} else if ($mAccount instanceof \RainLoop\Model\AdditionalAccount) {
|
} else if ($mAccount instanceof \RainLoop\Model\AdditionalAccount) {
|
||||||
$sEmail = $mAccount->ParentEmail();
|
$sEmail = $mAccount->ParentEmail();
|
||||||
|
|
@ -105,6 +106,7 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sEmail) {
|
if ($sEmail) {
|
||||||
|
// these are never local
|
||||||
if (StorageType::SIGN_ME === $iStorageType) {
|
if (StorageType::SIGN_ME === $iStorageType) {
|
||||||
$sSubFolder = '.sign_me';
|
$sSubFolder = '.sign_me';
|
||||||
} else if (StorageType::SESSION === $iStorageType) {
|
} else if (StorageType::SESSION === $iStorageType) {
|
||||||
|
|
@ -116,15 +118,11 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sFilePath = '';
|
|
||||||
switch ($iStorageType)
|
switch ($iStorageType)
|
||||||
{
|
{
|
||||||
case StorageType::NOBODY:
|
case StorageType::CONFIG:
|
||||||
$sFilePath = $this->sDataPath.'/__nobody__/';
|
|
||||||
break;
|
|
||||||
case StorageType::SIGN_ME:
|
case StorageType::SIGN_ME:
|
||||||
case StorageType::SESSION:
|
case StorageType::SESSION:
|
||||||
case StorageType::CONFIG:
|
|
||||||
case StorageType::PGP:
|
case StorageType::PGP:
|
||||||
case StorageType::ROOT:
|
case StorageType::ROOT:
|
||||||
if (empty($sEmail)) {
|
if (empty($sEmail)) {
|
||||||
|
|
@ -143,6 +141,7 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
||||||
default:
|
default:
|
||||||
throw new \Exception("Invalid storage type {$iStorageType}");
|
throw new \Exception("Invalid storage type {$iStorageType}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($bMkDir && !empty($sFilePath) && !\is_dir($sFilePath) && !\mkdir($sFilePath, 0700, true))
|
if ($bMkDir && !empty($sFilePath) && !\is_dir($sFilePath) && !\mkdir($sFilePath, 0700, true))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue