Commit dbc410cc authored by Etienne CHAMPETIER's avatar Etienne CHAMPETIER

ZP-641 fix cleanup of permanent backend storage.

Released under the Affero GNU General Public License (AGPL) version 3.
Signed-off-by: 's avatarEtienne CHAMPETIER <champetier.etienne@gmail.com>
parent 7538a6d8
......@@ -195,11 +195,6 @@ 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,7 +60,6 @@ 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, IStateMachine::HIGHEST_COUNTER);
ZPush::GetStateMachine()->CleanStates($devid, IStateMachine::BACKENDSTORAGE, sha1($user));
// remove devicedata and unlink user from device
unset($devices[$user]);
......@@ -291,8 +291,11 @@ class ZPushAdmin {
ZPush::GetStateMachine()->UnLinkUserDevice($user, $devid);
// no more users linked for device - remove device data
if (count($devices) == 0)
if (count($devices) == 0) {
ZPush::GetStateMachine()->CleanStates($devid, IStateMachine::DEVICEDATA, false);
//clean possible left over if FileStateMachine->AddKeyToState was never called
ZPush::GetStateMachine()->CleanStates($devid, IStateMachine::BACKENDSTORAGE, false);
}
// save data if something left
else
......
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