Skip to content

Commit

Permalink
Added overwrite option to storage-link command (#215)
Browse files Browse the repository at this point in the history
* Added overwrite option to storage-link command

* fix
  • Loading branch information
daVitekPL authored Nov 8, 2024
1 parent a4512fc commit e3e5d97
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/Commands/StorageH5PLinkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class StorageH5PLinkCommand extends Command
*
* @var string
*/
protected $signature = 'h5p:storage-link {--relative : Create the symbolic link using relative paths}';
protected $signature = 'h5p:storage-link {--relative : Create the symbolic link using relative paths} {--overwrite : Overwrite files if they existed before}';

/**
* The console command description.
Expand All @@ -31,16 +31,19 @@ class StorageH5PLinkCommand extends Command
public function handle()
{
$relative = $this->option('relative');
$overwrite = $this->option('overwrite');

$links = $this->links();

foreach ($links as $link => $target) {
if (Storage::directoryExists($link)) {
try {
Storage::assertDirectoryEmpty($link);
} catch (ExpectationFailedException $e) {
$this->error("The [$link] link already exists.");
continue;
if (!$overwrite) {
if (Storage::directoryExists($link)) {
try {
Storage::assertDirectoryEmpty($link);
} catch (ExpectationFailedException $e) {
$this->error("The [$link] link already exists.");
continue;
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion tests/Api/LibraryApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,11 @@ public function test_reinstall_library_dependencies()
$libraryDependencies = H5PLibraryDependency::where('library_id', $library->getKey());
$libraryDependenciesCount = $libraryDependencies->count();

if ($libraryDependencies->count() > 0) {
$libraryDependencies->first()->delete();

$libraryDependencies->first()->delete();
$this->assertNotEquals($libraryDependenciesCount, $libraryDependencies->count());
}

$this->assertNotEquals($libraryDependenciesCount, $libraryDependencies->count());

Check failure on line 323 in tests/Api/LibraryApiTest.php

View workflow job for this annotation

GitHub Actions / phpunit-code-coverage

Failed asserting that 0 is not equal to 0.

Expand Down

0 comments on commit e3e5d97

Please sign in to comment.