snappymail/plugins/demo-account/storage.php

25 lines
870 B
PHP
Raw Normal View History

<?php
class DemoStorage extends \RainLoop\Providers\Storage\FileStorage
{
/**
2021-11-09 00:40:21 +08:00
* @param \RainLoop\Model\Account|string|null $mAccount
*/
2021-11-09 00:40:21 +08:00
protected function generateFileName($mAccount, int $iStorageType, string $sKey, bool $bMkDir = false, bool $bForDeleteAction = false) : string
{
2021-11-09 00:40:21 +08:00
if (\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY === $iStorageType) {
return parent::generateFileName($mAccount, $iStorageType, $sKey, $bMkDir, $bForDeleteAction);
}
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) : '');
}
}