mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-02-07 06:16:43 +01:00
#4: The file size updating method no longer overwrites file size estimates for un-cached files with null.
This commit is contained in:
parent
2d93ed0ef4
commit
4214dde7b0
2 changed files with 14 additions and 8 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace Poniverse\Ponyfm\Console\Commands;
|
||||
|
||||
use File;
|
||||
use Illuminate\Console\Command;
|
||||
use Poniverse\Ponyfm\TrackFile;
|
||||
|
||||
|
@ -67,8 +68,10 @@ class RebuildFilesizes extends Command
|
|||
$this->info('========== Start Chunk ==========');
|
||||
|
||||
foreach ($trackFiles as $trackFile) {
|
||||
$size = $trackFile->updateFilesize();
|
||||
if ($size !== null) {
|
||||
/** @var TrackFile $trackFile */
|
||||
|
||||
if (File::exists($trackFile->getFile())) {
|
||||
$size = $trackFile->updateFilesize();
|
||||
$this->info('ID ' . $trackFile->id . ' processed - ' . $size . ' bytes');
|
||||
} else {
|
||||
$this->info('ID ' . $trackFile->id . ' skipped');
|
||||
|
|
|
@ -126,19 +126,22 @@ class TrackFile extends Model
|
|||
return 'track_file-' . $this->id . '-' . $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this file exists, update its estimated filesize in the database.
|
||||
*
|
||||
* @return int $size
|
||||
*/
|
||||
public function updateFilesize()
|
||||
{
|
||||
$file = $this->getFile();
|
||||
|
||||
if (File::exists($file)) {
|
||||
$size = File::size($file);
|
||||
} else {
|
||||
$size = null;
|
||||
|
||||
$this->filesize = $size;
|
||||
$this->update();
|
||||
}
|
||||
|
||||
$this->filesize = $size;
|
||||
$this->update();
|
||||
|
||||
return $size;
|
||||
return $this->filesize;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue