Added handling of created_manual, revert some file_path()

This commit is contained in:
Deon George 2020-01-05 18:02:32 +11:00
parent 0b6b3021fd
commit 270f63144b
4 changed files with 30 additions and 7 deletions

View File

@ -81,8 +81,10 @@ class CatalogScan extends Command
}
// If the file signature changed, abort the update.
if ($o->getOriginal('file_signature') AND $o->getDirty('file_signature'))
if ($o->getOriginal('file_signature') AND $o->wasChanged('file_signature')) {
dump(['old'=>$o->getOriginal('file_signature'),'new'=>$o->file_signature]);
abort(500,'File Signature Changed?');
}
$o->save();
}

View File

@ -65,6 +65,6 @@ class VideoController extends Controller
public function view(Video $o)
{
if ($o->isReadable())
(new VideoStream($o->filename))->start();
(new VideoStream($o->file_path()))->start();
}
}

View File

@ -97,7 +97,21 @@ abstract class Catalog extends Model
->orWhere(function($q) {
// Or they have the same time taken with the same camera
if ($this->attributes['created'] AND $this->software_id) {
$q->where('created','=',$this->attributes['created'] ?: NULL);
$q->where(function ($q) {
$q->where('created','=',$this->attributes['created'])
->orWhere('created_manual','=',$this->attributes['created']);
});
if (static::$includeSubSecTime)
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
$q->where('software_id','=',$this->attributes['software_id']);
} elseif ($this->attributes['created_manual'] AND $this->software_id) {
$q->where(function ($q) {
$q->where('created','=',$this->attributes['created_manual'])
->orWhere('created_manual','=',$this->attributes['created_manual']);
});
if (static::$includeSubSecTime)
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
@ -272,6 +286,11 @@ abstract class Catalog extends Model
return (! is_readable($this->file_path())) ? NULL : filesize($this->file_path());
}
public function getCreatedAttribute(): Carbon
{
return $this->created_manual ?: $this->asDateTime($this->attributes['created']);
}
/**
* Return item dimensions
*/
@ -314,10 +333,6 @@ abstract class Catalog extends Model
return $this->HTMLCheckbox('ignore_duplicate',$this->id,$this->ignore_duplicate);
}
public function getDateCreatedAttribute() {
return $this->attributes['date_created'] ? Carbon::createFromTimestamp($this->attributes['date_created']) : NULL;
}
/**
* @deprecated
*/

View File

@ -8,6 +8,7 @@ class Video extends Abstracted\Catalog
{
// ID3 Object
private $_o = NULL;
protected $dates = ['created','created_manual'];
public function getIDLinkAttribute()
{
@ -124,6 +125,11 @@ class Video extends Abstracted\Catalog
return isset($data[$key]) ? $data[$key] : NULL;
}
public function setDateCreated()
{
$this->created = strtotime($this->property('creationdate'));
}
public function setLocation()
{
$this->gps_lat = $this->property('gps_lat');