Skip to content

Commit

Permalink
Merge pull request #59 from getkirby/feature/clear-locks
Browse files Browse the repository at this point in the history
New `clear:lock` command
  • Loading branch information
bastianallgeier authored Feb 22, 2024
2 parents 1b7d168 + b59cd06 commit 1a37e3d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions commands/clear/lock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types = 1);

use Kirby\CLI\CLI;
use Kirby\Filesystem\F;

return [
'description' => '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');
}
];

0 comments on commit 1a37e3d

Please sign in to comment.