Add IGNORE_DOT_FILES setting

With this .env setting, user can specify Koel to ignore dot files and
folders (default) or include them during scanning.
This commit is contained in:
An Phan 2016-09-17 23:56:58 +08:00
parent 7c378ac78f
commit e4f0027f6a
No known key found for this signature in database
GPG key ID: 05536BB4BCDC02A2
5 changed files with 27 additions and 2 deletions

View file

@ -22,6 +22,10 @@ APP_KEY=
# Another random 32-char string. You can leave this empty if use php artisan koel:init.
JWT_SECRET=
# By default, Koel ignore dot files and folders. This greatly improve performance if your media
# root have folders like .git or .cache. If by any chance your media files are under a dot folder,
# set the following setting to false.
IGNORE_DOT_FILES=true
APP_ENV=production
APP_DEBUG=true

View file

@ -119,7 +119,7 @@ class Media
{
return Finder::create()
->ignoreUnreadableDirs()
->ignoreDotFiles(false) // https://github.com/phanan/koel/issues/450
->ignoreDotFiles((bool) config('koel.ingore_dot_files')) // https://github.com/phanan/koel/issues/450
->files()
->followLinks()
->name('/\.(mp3|ogg|m4a|flac)$/i')

View file

@ -100,4 +100,14 @@ return [
'allow' => env('ALLOW_DOWNLOAD', true),
],
/*
|--------------------------------------------------------------------------
| Ignore Dot Files
|--------------------------------------------------------------------------
|
| Ignore dot files and folders when scanning for media files.
|
*/
'ingore_dot_files' => env('IGNORE_DOT_FILES', true),
];

View file

@ -63,7 +63,6 @@ class MediaTest extends TestCase
$this->assertTrue($song->album->is_compilation);
$this->assertEquals(Artist::VARIOUS_ID, $song->album->artist_id);
$currentCover = $album->cover;
$song = Song::orderBy('id', 'desc')->first();
@ -214,4 +213,16 @@ class MediaTest extends TestCase
$this->assertEquals('小岩井こ Random', $info['album']);
$this->assertEquals('水谷広実', $info['title']);
}
public function testDotDirectories()
{
config(['koel.ingore_dot_files' => false]);
$media = new Media();
$media->sync($this->mediaPath);
$this->seeInDatabase('albums', ['name' => 'Hidden Album']);
config(['koel.ingore_dot_files' => true]);
$media->sync($this->mediaPath);
$this->notSeeInDatabase('albums', ['name' => 'Hidden Album']);
}
}

BIN
tests/songs/.hidden/foo.mp3 Normal file

Binary file not shown.