mirror of
https://github.com/koel/koel
synced 2025-02-26 12:17:12 +00:00
Merge branch 'master' into test
This commit is contained in:
commit
72ff0b76cc
2 changed files with 25 additions and 4 deletions
|
@ -6,6 +6,7 @@ use Exception;
|
|||
use getID3;
|
||||
use getid3_lib;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Media;
|
||||
use SplFileInfo;
|
||||
|
||||
class File
|
||||
|
@ -179,6 +180,11 @@ class File
|
|||
return false;
|
||||
}
|
||||
|
||||
// Fixes #366. If the file is new, we use all tags by simply setting $force to false.
|
||||
if ($this->isNew()) {
|
||||
$force = false;
|
||||
}
|
||||
|
||||
$artist = null;
|
||||
|
||||
if ($this->isChanged() || $force) {
|
||||
|
@ -240,10 +246,7 @@ class File
|
|||
// Remove these values from the info array, so that we can just use the array as model's input data.
|
||||
array_forget($info, ['artist', 'albumartist', 'album', 'cover', 'compilation']);
|
||||
|
||||
$song = Song::updateOrCreate(['id' => $this->hash], $info);
|
||||
$song->save();
|
||||
|
||||
return $song;
|
||||
return Song::updateOrCreate(['id' => $this->hash], $info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -132,6 +132,24 @@ class MediaTest extends TestCase
|
|||
$this->assertEquals('Booom Wroooom', $song->lyrics);
|
||||
}
|
||||
|
||||
public function testAlwaysSyncAllTagsIfFileIsNew()
|
||||
{
|
||||
$media = new Media();
|
||||
$media->sync($this->mediaPath);
|
||||
$song = Song::orderBy('id')->first();
|
||||
$song->delete();
|
||||
|
||||
// Selectively sync only one tag,
|
||||
// but we still expect the whole song to be added back with all info
|
||||
$media->sync($this->mediaPath, ['track'], true);
|
||||
$this->seeInDatabase('songs', [
|
||||
'id' => $song->id,
|
||||
'lyrics' => $song->lyrics,
|
||||
'title' => $song->title,
|
||||
'track' => $song->track,
|
||||
]);
|
||||
}
|
||||
|
||||
public function testWatchSingleFileAdded()
|
||||
{
|
||||
$path = $this->mediaPath.'/blank.mp3';
|
||||
|
|
Loading…
Add table
Reference in a new issue