diff --git a/src/Lock.php b/src/Lock.php index f7e2993b7..56ba6f0e2 100644 --- a/src/Lock.php +++ b/src/Lock.php @@ -20,6 +20,7 @@ class Lock { private $json; private $lock = []; + private $changed = false; public function __construct($lockFile) { @@ -38,6 +39,7 @@ public function add($name, $data) { $current = $this->lock[$name] ?? []; $this->lock[$name] = array_merge($current, $data); + $this->changed = true; } public function get($name) @@ -48,15 +50,21 @@ public function get($name) public function set($name, $data) { $this->lock[$name] = $data; + $this->changed = true; } public function remove($name) { unset($this->lock[$name]); + $this->changed = true; } public function write() { + if (!$this->changed) { + return; + } + if ($this->lock) { ksort($this->lock); $this->json->write($this->lock);