mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-31 03:52:01 +08:00
24 lines
870 B
PHP
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) : '');
|
|
}
|
|
}
|