remove a file before overwriting it with file_put_contents

This commit is contained in:
<bdauvergne@entrouvert.com> 1206639877 +0100 0001-01-01 00:00:00 +00:00
parent ca28cd7cf9
commit 494d8a262d
1 changed files with 3 additions and 1 deletions

View File

@ -23,7 +23,9 @@ class LassoSPKitFileStore implements LassoSPKitStore {
}
function set($key, $value) {
if ($key && $key != "") {
$ret = @file_put_contents($this->filepath($key), @serialize($value));
$path = $this->filepath($key);
@unlink($path);
$ret = @file_put_contents($path, @serialize($value));
$this->debug($ret, "cannot set contents of file " . $this->filepath($key));
} else {
throw new Exception("Bad usage of FileStore::set, key is null");