2015-02-13 01:54:12 +08:00
|
|
|
<?php
|
|
|
|
|
2021-10-25 15:45:22 +08:00
|
|
|
class DemoStorage extends \RainLoop\Providers\Storage\FileStorage
|
2015-02-13 01:54:12 +08:00
|
|
|
{
|
|
|
|
/**
|
2021-11-09 00:40:21 +08:00
|
|
|
* @param \RainLoop\Model\Account|string|null $mAccount
|
2015-02-13 01:54:12 +08:00
|
|
|
*/
|
2021-11-09 00:40:21 +08:00
|
|
|
protected function generateFileName($mAccount, int $iStorageType, string $sKey, bool $bMkDir = false, bool $bForDeleteAction = false) : string
|
2015-02-13 01:54:12 +08:00
|
|
|
{
|
2021-11-09 00:40:21 +08:00
|
|
|
if (\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY === $iStorageType) {
|
|
|
|
return parent::generateFileName($mAccount, $iStorageType, $sKey, $bMkDir, $bForDeleteAction);
|
2015-02-13 01:54:12 +08:00
|
|
|
}
|
|
|
|
|
2021-11-09 00:52:40 +08:00
|
|
|
$sDataPath = "{$this->sDataPath}/demo";
|
|
|
|
if (\is_dir($sDataPath) && 0 === \random_int(0, 100)) {
|
|
|
|
\MailSo\Base\Utils::RecRmDir("{$this->sDataPath}/demo");
|
|
|
|
}
|
|
|
|
|
2021-11-30 18:18:52 +08:00
|
|
|
$sDataPath .= '/' . \RainLoop\Utils::fixName(\RainLoop\Utils::GetConnectionToken());
|
2021-11-09 00:52:40 +08:00
|
|
|
\is_dir($sDataPath) || \mkdir($sDataPath, 0700, true);
|
|
|
|
|
2021-11-30 18:18:52 +08:00
|
|
|
return $sDataPath . '/' . ($sKey ? \RainLoop\Utils::fixName($sKey) : '');
|
2015-02-13 01:54:12 +08:00
|
|
|
}
|
|
|
|
}
|