More folderlist speedups

This commit is contained in:
djmaze 2021-10-29 10:08:42 +02:00
parent 76630f593d
commit 12ebe4c3a0
4 changed files with 12 additions and 16 deletions

View file

@ -155,7 +155,7 @@ class ImapClient extends \MailSo\Net\NetClient
try try
{ {
if (0 === \strpos($type, 'SCRAM-SHA-')) if (0 === \strpos($type, 'SCRAM-'))
{ {
$sAuthzid = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), Enumerations\ResponseType::CONTINUATION); $sAuthzid = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), Enumerations\ResponseType::CONTINUATION);
$this->sendRaw($SASL->authenticate($sLogin, $sPassword/*, $sAuthzid*/), true); $this->sendRaw($SASL->authenticate($sLogin, $sPassword/*, $sAuthzid*/), true);
@ -759,7 +759,7 @@ class ImapClient extends \MailSo\Net\NetClient
private function simpleESearchOrESortHelper(bool $bSort = false, string $sSearchCriterias = 'ALL', array $aSearchOrSortReturn = null, bool $bReturnUid = true, string $sLimit = '', string $sCharset = '', array $aSortTypes = null) : array private function simpleESearchOrESortHelper(bool $bSort = false, string $sSearchCriterias = 'ALL', array $aSearchOrSortReturn = null, bool $bReturnUid = true, string $sLimit = '', string $sCharset = '', array $aSortTypes = null) : array
{ {
$sCommandPrefix = ($bReturnUid) ? 'UID ' : ''; $sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = 0 === \strlen($sSearchCriterias) || '*' === $sSearchCriterias $sSearchCriterias = !\strlen($sSearchCriterias) || '*' === $sSearchCriterias
? 'ALL' : $sSearchCriterias; ? 'ALL' : $sSearchCriterias;
$sCmd = $bSort ? 'SORT': 'SEARCH'; $sCmd = $bSort ? 'SORT': 'SEARCH';
@ -939,7 +939,7 @@ class ImapClient extends \MailSo\Net\NetClient
*/ */
public function MessageCopy(string $sToFolder, string $sIndexRange, bool $bIndexIsUid) : self public function MessageCopy(string $sToFolder, string $sIndexRange, bool $bIndexIsUid) : self
{ {
if (0 === \strlen($sIndexRange)) if (!\strlen($sIndexRange))
{ {
$this->writeLogException( $this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException, new \MailSo\Base\Exceptions\InvalidArgumentException,
@ -959,7 +959,7 @@ class ImapClient extends \MailSo\Net\NetClient
*/ */
public function MessageMove(string $sToFolder, string $sIndexRange, bool $bIndexIsUid) : self public function MessageMove(string $sToFolder, string $sIndexRange, bool $bIndexIsUid) : self
{ {
if (0 === \strlen($sIndexRange)) if (!\strlen($sIndexRange))
{ {
$this->writeLogException( $this->writeLogException(
new \MailSo\Base\Exceptions\InvalidArgumentException, new \MailSo\Base\Exceptions\InvalidArgumentException,

View file

@ -180,7 +180,7 @@ class ResponseCollection extends \MailSo\Base\Collection
$sDelimiter = $oFolder->Delimiter(); $sDelimiter = $oFolder->Delimiter();
} }
$aReturn[] = $oFolder; $aReturn[$sFullNameRaw] = $oFolder;
} }
catch (\MailSo\Base\Exceptions\InvalidArgumentException $oException) catch (\MailSo\Base\Exceptions\InvalidArgumentException $oException)
{ {
@ -197,8 +197,8 @@ class ResponseCollection extends \MailSo\Base\Collection
} }
} }
if (!$bInbox && !empty($sDelimiter)) { if (!$bInbox && !empty($sDelimiter) && !isset($aReturn['INBOX'])) {
$aReturn[] = new Folder('INBOX', $sDelimiter); $aReturn['INBOX'] = new Folder('INBOX', $sDelimiter);
} }
if ($bUseListStatus) { if ($bUseListStatus) {
@ -208,11 +208,8 @@ class ResponseCollection extends \MailSo\Base\Collection
isset($oResponse->ResponseList[2])) isset($oResponse->ResponseList[2]))
{ {
$sFolderNameRaw = $oResponse->ResponseList[2]; $sFolderNameRaw = $oResponse->ResponseList[2];
foreach ($aReturn as $oFolder) { if (isset($aReturn[$sFolderNameRaw])) {
if ($oFolder && $sFolderNameRaw === $oFolder->FullNameRaw()) { $aReturn[$sFolderNameRaw]->setStatusFromResponse($oResponse);
$oFolder->setStatusFromResponse($oResponse);
break;
}
} }
} }
} }

View file

@ -492,7 +492,7 @@ trait ResponseParser
{ {
$bCountTwoInited = true; $bCountTwoInited = true;
$oImapResponse->StatusOrIndex = strtoupper($aList[1]); $oImapResponse->StatusOrIndex = \strtoupper($aList[1]);
if ($oImapResponse->StatusOrIndex == ResponseStatus::OK || if ($oImapResponse->StatusOrIndex == ResponseStatus::OK ||
$oImapResponse->StatusOrIndex == ResponseStatus::NO || $oImapResponse->StatusOrIndex == ResponseStatus::NO ||

View file

@ -1976,14 +1976,13 @@ class MailClient
throw new \MailSo\Base\Exceptions\InvalidArgumentException; throw new \MailSo\Base\Exceptions\InvalidArgumentException;
} }
$aFolders = $this->oImapClient->FolderList('', $sPrevFolderFullNameRaw); $sDelimiter = $this->oImapClient->FolderHierarchyDelimiter($sPrevFolderFullNameRaw);
if (!$aFolders) if (!$sDelimiter)
{ {
// TODO: Translate // TODO: Translate
throw new Exceptions\RuntimeException('Cannot '.($bRename?'rename':'move').' non-existent folder.'); throw new Exceptions\RuntimeException('Cannot '.($bRename?'rename':'move').' non-existent folder.');
} }
$sDelimiter = $aFolders[0]->Delimiter();
$iLast = \strrpos($sPrevFolderFullNameRaw, $sDelimiter); $iLast = \strrpos($sPrevFolderFullNameRaw, $sDelimiter);
$aSubscribeFolders = array(); $aSubscribeFolders = array();