Commit 7538a6d8 authored by Etienne CHAMPETIER's avatar Etienne CHAMPETIER

ZP-641 migrate old permanent backend storage file.

Released under the Affero GNU General Public License (AGPL) version 3.

this avoid a full resync of all imap users (at least)
Signed-off-by: 's avatarEtienne CHAMPETIER <champetier.etienne@gmail.com>
parent 04edd24d
...@@ -120,6 +120,9 @@ class FileStateMachine implements IStateMachine { ...@@ -120,6 +120,9 @@ class FileStateMachine implements IStateMachine {
* @throws StateNotFoundException, StateInvalidException * @throws StateNotFoundException, StateInvalidException
*/ */
public function GetState($devid, $type, $key = false, $counter = false, $cleanstates = true) { public function GetState($devid, $type, $key = false, $counter = false, $cleanstates = true) {
if ($type == IStateMachine::BACKENDSTORAGE && $key && strlen($key) == 40) {
$this->AddKeyToState($devid, $type, $key, $counter);
}
if ($counter && $cleanstates) if ($counter && $cleanstates)
$this->CleanStates($devid, $type, $key, $counter); $this->CleanStates($devid, $type, $key, $counter);
...@@ -137,6 +140,22 @@ class FileStateMachine implements IStateMachine { ...@@ -137,6 +140,22 @@ class FileStateMachine implements IStateMachine {
throw new StateNotFoundException(sprintf("FileStateMachine->GetState(): Could not locate state '%s'",$filename)); throw new StateNotFoundException(sprintf("FileStateMachine->GetState(): Could not locate state '%s'",$filename));
} }
/**
* function to migrate old backendstorage state
*
* @param string $devid the device id
* @param string $type the state type
* @param string $key the state key
* @param string $counter the state counter
*/
private function AddKeyToState($devid, $type, $key, $counter) {
$old = $this->getFullFilePath($devid, $type, false, $counter);
$new = $this->getFullFilePath($devid, $type, $key, $counter);
if (@rename($old, $new)) {
ZLog::Write(LOGLEVEL_INFO, sprintf("FileStateMachine->AddKeyToState() on file: '%s'", $new));
}
}
/** /**
* Writes ta state to for a key and counter * Writes ta state to for a key and counter
* *
......
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