diff --git a/README.md b/README.md index 7580bd0..c7d4016 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ This should print the Kirby CLI version and a list of available commands ``` - kirby clean:content - kirby clear:cache +- kirby clear:lock - kirby clear:media - kirby clear:sessions - kirby download diff --git a/commands/clear/lock.php b/commands/clear/lock.php new file mode 100644 index 0000000..631cbd6 --- /dev/null +++ b/commands/clear/lock.php @@ -0,0 +1,25 @@ + 'Deletes the content `.lock` files', + 'command' => static function (CLI $cli): void { + $path = $cli->kirby()->root('content'); + $directoryIterator = new RecursiveDirectoryIterator($path); + $iterator = new RecursiveIteratorIterator($directoryIterator); + $counter = 0; + + foreach ($iterator as $file) { + if ($file->getFilename() === '.lock') { + F::remove($file->getPathName()); + $counter++; + } + } + + $cli->success($counter . ' lock file(s) have been deleted'); + } +];