mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-03-20 18:27:11 +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;
|
namespace Poniverse\Ponyfm\Console\Commands;
|
||||||
|
|
||||||
|
use File;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Poniverse\Ponyfm\TrackFile;
|
use Poniverse\Ponyfm\TrackFile;
|
||||||
|
|
||||||
|
@ -67,8 +68,10 @@ class RebuildFilesizes extends Command
|
||||||
$this->info('========== Start Chunk ==========');
|
$this->info('========== Start Chunk ==========');
|
||||||
|
|
||||||
foreach ($trackFiles as $trackFile) {
|
foreach ($trackFiles as $trackFile) {
|
||||||
$size = $trackFile->updateFilesize();
|
/** @var TrackFile $trackFile */
|
||||||
if ($size !== null) {
|
|
||||||
|
if (File::exists($trackFile->getFile())) {
|
||||||
|
$size = $trackFile->updateFilesize();
|
||||||
$this->info('ID ' . $trackFile->id . ' processed - ' . $size . ' bytes');
|
$this->info('ID ' . $trackFile->id . ' processed - ' . $size . ' bytes');
|
||||||
} else {
|
} else {
|
||||||
$this->info('ID ' . $trackFile->id . ' skipped');
|
$this->info('ID ' . $trackFile->id . ' skipped');
|
||||||
|
|
|
@ -126,19 +126,22 @@ class TrackFile extends Model
|
||||||
return 'track_file-' . $this->id . '-' . $key;
|
return 'track_file-' . $this->id . '-' . $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this file exists, update its estimated filesize in the database.
|
||||||
|
*
|
||||||
|
* @return int $size
|
||||||
|
*/
|
||||||
public function updateFilesize()
|
public function updateFilesize()
|
||||||
{
|
{
|
||||||
$file = $this->getFile();
|
$file = $this->getFile();
|
||||||
|
|
||||||
if (File::exists($file)) {
|
if (File::exists($file)) {
|
||||||
$size = File::size($file);
|
$size = File::size($file);
|
||||||
} else {
|
|
||||||
$size = null;
|
$this->filesize = $size;
|
||||||
|
$this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->filesize = $size;
|
return $this->filesize;
|
||||||
$this->update();
|
|
||||||
|
|
||||||
return $size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue