Commit 0cbe61f5 authored by Sebastian Kummer's avatar Sebastian Kummer

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

Merge pull request #7 in ZP/z-push from bugfix/ZP-641-filestatemachine-backend-storage-file to develop

* commit 'f087cedd':
  ZP-641 Make sure CleanStates does not touch permanent backend storage files, unless we really want to delete them.
  ZP-641 Revert "For Backend Storage type files, add a user element to the file name so that multiple accounts on the same device do not overwrite each others data in a single file named only for the device."
  For Backend Storage type files, add a user element to the file name so that multiple accounts on the same device do not overwrite each others data in a single file named only for the device.
parents 6c311642 f087cedd
......@@ -176,6 +176,11 @@ class FileStateMachine implements IStateMachine {
* @throws StateInvalidException
*/
public function CleanStates($devid, $type, $key, $counter = false) {
// Don't remove permanent backend storage files, unless we explicitily want that
if ($key === false && $type === IStateMachine::BACKENDSTORAGE && $counter != IStateMachine::HIGHEST_COUNTER) {
return;
}
$matching_files = glob($this->getFullFilePath($devid, $type, $key). "*", GLOB_NOSORT);
if (is_array($matching_files)) {
foreach($matching_files as $state) {
......
......@@ -60,6 +60,7 @@ interface IStateMachine {
const FAILSAVE = "fs";
const HIERARCHY = "hc";
const BACKENDSTORAGE = "bs";
const HIGHEST_COUNTER = 99999999999;
const STATEVERSION_01 = "1"; // Z-Push 2.0.x - default value if unset
const STATEVERSION_02 = "2"; // Z-Push 2.1.0 Milestone 1
......
......@@ -282,7 +282,7 @@ class ZPushAdmin {
StateManager::UnLinkState($device, false);
// remove backend storage permanent data
ZPush::GetStateMachine()->CleanStates($device->GetDeviceId(), IStateMachine::BACKENDSTORAGE, false, 99999999999);
ZPush::GetStateMachine()->CleanStates($device->GetDeviceId(), IStateMachine::BACKENDSTORAGE, false, IStateMachine::HIGHEST_COUNTER);
// remove devicedata and unlink user from device
unset($devices[$user]);
......
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