Commit 42ed08fa authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #404 in ZP/z-push from...

Merge pull request #404 in ZP/z-push from bugfix/ZP-1087-short-folderid-hash-collisions-on to develop

* commit '844e925b':
  ZP-1087 Also check backend2folderidCache for generated but not (yet) synchronized short folderids when hashing.
parents 4260a916 844e925b
...@@ -1041,7 +1041,7 @@ class ASDevice extends StateObject { ...@@ -1041,7 +1041,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)
...@@ -1057,7 +1057,7 @@ class ASDevice extends StateObject { ...@@ -1057,7 +1057,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