Commit 5c7a4b19 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-641 Delete file only if it exists.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 7c89199f
...@@ -180,10 +180,12 @@ class FileStateMachine implements IStateMachine { ...@@ -180,10 +180,12 @@ class FileStateMachine implements IStateMachine {
// TODO remove this block and implement it as described in ZP-835 // TODO remove this block and implement it as described in ZP-835
if ($key === false && $type === IStateMachine::BACKENDSTORAGE) { if ($key === false && $type === IStateMachine::BACKENDSTORAGE) {
$file = $this->getFullFilePath($devid, $type, $key, $counter); $file = $this->getFullFilePath($devid, $type, $key, $counter);
if (file_exists($file)) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("FileStateMachine->CleanStates(): Deleting 'bs' file: '%s'", $file)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("FileStateMachine->CleanStates(): Deleting 'bs' file: '%s'", $file));
unlink($file); unlink($file);
return; return;
} }
}
$matching_files = glob($this->getFullFilePath($devid, $type, $key). "*", GLOB_NOSORT); $matching_files = glob($this->getFullFilePath($devid, $type, $key). "*", GLOB_NOSORT);
if (is_array($matching_files)) { if (is_array($matching_files)) {
......
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