[GH-ISSUE #572] Error in 'php artisan koel:sync' because '/covers' subdirectory of 'public/img/' is not created by default #412

Closed
opened 2026-02-26 02:33:08 +03:00 by kerem · 1 comment
Owner

Originally created by @nitePhyyre on GitHub (Apr 13, 2017).
Original GitHub issue: https://github.com/koel/koel/issues/572

Hi,

I had a fresh install of 3.6.0.
In file app/Models/Album.php:

public function copyCoverFile($srcPath)
{
    $extension = pathinfo($srcPath, PATHINFO_EXTENSION);
    $destPath = $this->generateRandomCoverPath($extension);
    copy($srcPath, $destPath);
    $this->update(['cover' => basename($destPath)]);
}

private function generateRandomCoverPath($extension)
{
    return app()->publicPath().'/public/img/covers/'.uniqid('', true).".$extension";
}

The line copy($srcPath, $destPath); is causing the following error:
[ErrorException] copy(/var/www/public/img/covers/58eeea295471a5.02522229.jpg): failed to open stream: No such file or directory

Because while app()->publicPath().'/public/img/' existed on the new install. The /covers subdirectory didn't. Creating the directory allowed me to run the import.

Originally created by @nitePhyyre on GitHub (Apr 13, 2017). Original GitHub issue: https://github.com/koel/koel/issues/572 Hi, I had a fresh install of 3.6.0. In file app/Models/Album.php: ``` public function copyCoverFile($srcPath) { $extension = pathinfo($srcPath, PATHINFO_EXTENSION); $destPath = $this->generateRandomCoverPath($extension); copy($srcPath, $destPath); $this->update(['cover' => basename($destPath)]); } private function generateRandomCoverPath($extension) { return app()->publicPath().'/public/img/covers/'.uniqid('', true).".$extension"; } ``` The line `copy($srcPath, $destPath);` is causing the following error: `[ErrorException] copy(/var/www/public/img/covers/58eeea295471a5.02522229.jpg): failed to open stream: No such file or directory` Because while `app()->publicPath().'/public/img/'` existed on the new install. The `/covers` subdirectory didn't. Creating the directory allowed me to run the import.
kerem closed this issue 2026-02-26 02:33:08 +03:00
Author
Owner

@etbusch commented on GitHub (Apr 14, 2017):

Also encountered this bug

<!-- gh-comment-id:294079323 --> @etbusch commented on GitHub (Apr 14, 2017): Also encountered this bug
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#412
No description provided.