Commit ae2f8019 authored by skummer's avatar skummer

ZP-308 #comment write state version on new install #time 30m


git-svn-id: https://z-push.org/svn/z-push/trunk@1614 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 27d63c2e
......@@ -46,6 +46,7 @@
************************************************/
class FileStateMachine implements IStateMachine {
const SUPPORTED_STATE_VERSION = IStateMachine::STATEVERSION_02;
const VERSION = "version";
private $userfilename;
......@@ -331,8 +332,15 @@ class FileStateMachine implements IStateMachine {
public function GetStateVersion() {
if (file_exists($this->settingsfilename))
$settings = unserialize(file_get_contents($this->settingsfilename));
else
$settings = array(self::VERSION => IStateMachine::STATEVERSION_01);
else {
$filecontents = @file_get_contents($this->userfilename);
if (is_array($filecontents))
$settings = array(self::VERSION => IStateMachine::STATEVERSION_01);
else {
$settings = array(self::VERSION => self::SUPPORTED_STATE_VERSION);
$this->SetStateVersion(self::SUPPORTED_STATE_VERSION);
}
}
return $settings[self::VERSION];
}
......@@ -352,6 +360,7 @@ class FileStateMachine implements IStateMachine {
array(self::VERSION => IStateMachine::STATEVERSION_01);
$settings[self::VERSION] = $version;
ZLog::Write(LOGLEVEL_INFO, sprintf("FileStateMachine->SetStateVersion() saving supported state version, value '%d'", $version));
return file_put_contents($this->settingsfilename, serialize($settings));
}
......
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