Determine current filename

This commit is contained in:
Deon George 2020-07-16 12:12:26 +10:00
parent ed49ef29b5
commit 18812b51e0
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
2 changed files with 14 additions and 4 deletions

View File

@ -42,14 +42,14 @@ class CatalogVerify extends Job implements ShouldQueue
$good = $bad = $ugly = 0; $good = $bad = $ugly = 0;
$class::select('*')->each(function($o) use ($good,$bad,$ugly) { $class::select('*')->each(function($o) use ($good,$bad,$ugly) {
if (! file_exists($o->file_name(FALSE))) { if (! file_exists($o->file_name_current(FALSE))) {
Log::error(sprintf('Media doesnt exist: [%s] (%d:%s)',$this->type,$o->id,$o->file_name(FALSE))); Log::error(sprintf('Media doesnt exist: [%s] (%d:%s)',$this->type,$o->id,$o->file_name_current(FALSE)));
$bad++; $bad++;
return; return;
} }
if (($x=md5_file($o->file_name(FALSE))) !== $o->file_signature) { if (($x=md5_file($o->file_name_current(FALSE))) !== $o->file_signature) {
Log::error(sprintf('Media MD5 doesnt match DB: [%s] (%d:%s) [%s:%s]',$this->type,$o->id,$o->file_name(FALSE),$x,$o->file_signature)); Log::error(sprintf('Media MD5 doesnt match DB: [%s] (%d:%s) [%s:%s]',$this->type,$o->id,$o->file_name_current(FALSE),$x,$o->file_signature));
$ugly++; $ugly++;
return; return;
} }

View File

@ -251,6 +251,16 @@ abstract class Catalog extends Model
return (($short OR preg_match('/^\//',$file)) ? '' : config($this->type.'.dir').DIRECTORY_SEPARATOR).$file; return (($short OR preg_match('/^\//',$file)) ? '' : config($this->type.'.dir').DIRECTORY_SEPARATOR).$file;
} }
/**
* Return the current filename
*
* @return string
*/
public function file_name_current(bool $short=TRUE): string
{
return (($short OR preg_match('/^\//',$this->filename)) ? '' : config($this->type.'.dir').DIRECTORY_SEPARATOR).$this->filename;
}
/** /**
* Determine the new name for the image * Determine the new name for the image
* @deprecated use $this->file_name() * @deprecated use $this->file_name()