Commit 844e925b authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1087 Also check backend2folderidCache for generated but not (yet)

synchronized short folderids when hashing.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 3e21a96f
...@@ -933,7 +933,7 @@ class ASDevice extends StateObject { ...@@ -933,7 +933,7 @@ class ASDevice extends StateObject {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->EditAdditionalFolder(): No valid folderid ('%s') or name ('%s') sent. Aborting. ", $folderid, $name)); ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->EditAdditionalFolder(): No valid folderid ('%s') or name ('%s') sent. Aborting. ", $folderid, $name));
return false; return false;
} }
// check if a folder with this ID is known // check if a folder with this ID is known
if (!isset($this->additionalfolders[$folderid])) { if (!isset($this->additionalfolders[$folderid])) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->EditAdditionalFolder(): folder can not be edited because there is no folder known with this folder id: '%s'. Add the folder first.", $folderid)); ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->EditAdditionalFolder(): folder can not be edited because there is no folder known with this folder id: '%s'. Add the folder first.", $folderid));
...@@ -995,7 +995,7 @@ class ASDevice extends StateObject { ...@@ -995,7 +995,7 @@ class ASDevice extends StateObject {
* Generates the AS folder hash from the backend folder id, type and name. * Generates the AS folder hash from the backend folder id, type and name.
* *
* @param string $backendid Backend folder id * @param string $backendid Backend folder id
* @param string $folderOrigin Folder type is one of 'U' (user) * @param string $folderOrigin Folder type is one of 'U' (user)
* 'C' (configured) * 'C' (configured)
* 'S' (shared) * 'S' (shared)
* 'G' (global address book) * 'G' (global address book)
...@@ -1011,7 +1011,7 @@ class ASDevice extends StateObject { ...@@ -1011,7 +1011,7 @@ class ASDevice extends StateObject {
$cnt = 0; $cnt = 0;
// Collision avoiding. Append an increasing number to the string to hash // Collision avoiding. Append an increasing number to the string to hash
// until there aren't any collisions. Probably a smaller number is also sufficient. // until there aren't any collisions. Probably a smaller number is also sufficient.
while (isset($this->contentData[$folderId]) && $cnt < 10000) { while ((isset($this->contentData[$folderId]) || in_array($folderId, $this->backend2folderidCache, true)) && $cnt < 10000) {
$folderId = substr($folderOrigin . dechex(crc32($backendid . $folderName . $cnt++)), 0, 6); $folderId = substr($folderOrigin . dechex(crc32($backendid . $folderName . $cnt++)), 0, 6);
ZLog::Write(LOGLEVEL_WARN, sprintf("ASDevice->generateFolderHash(): collision avoiding nr %05d. Generated hash: '%s'", $cnt, $folderId)); ZLog::Write(LOGLEVEL_WARN, sprintf("ASDevice->generateFolderHash(): collision avoiding nr %05d. Generated hash: '%s'", $cnt, $folderId));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment