snappymail/plugins/demo-account/storage.php
2021-11-30 11:18:52 +01:00

24 lines
870 B
PHP

<?php
class DemoStorage extends \RainLoop\Providers\Storage\FileStorage
{
/**
* @param \RainLoop\Model\Account|string|null $mAccount
*/
protected function generateFileName($mAccount, int $iStorageType, string $sKey, bool $bMkDir = false, bool $bForDeleteAction = false) : string
{
if (\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY === $iStorageType) {
return parent::generateFileName($mAccount, $iStorageType, $sKey, $bMkDir, $bForDeleteAction);
}
$sDataPath = "{$this->sDataPath}/demo";
if (\is_dir($sDataPath) && 0 === \random_int(0, 100)) {
\MailSo\Base\Utils::RecRmDir("{$this->sDataPath}/demo");
}
$sDataPath .= '/' . \RainLoop\Utils::fixName(\RainLoop\Utils::GetConnectionToken());
\is_dir($sDataPath) || \mkdir($sDataPath, 0700, true);
return $sDataPath . '/' . ($sKey ? \RainLoop\Utils::fixName($sKey) : '');
}
}