ScanDirectoryJob
extends BaseJob
in package
implements
ShouldQueue
Table of Contents
Interfaces
- ShouldQueue
Constants
- ARTIST_SEPARATOR = ';'
- GENRE_SEPARATOR = ';'
- BATCH_SIZE = 50
Properties
- $directory : string
- $library : Library
- $logger : LoggerInterface
- $loggerCache : array<string|int, mixed>
- $progressCurrentChunk : int
- Internal variable used for tracking chunking progress.
- $progressLastUpdated : int|null
- The unix timestamp explaining the last time a progress has been written to database.
Methods
- __construct() : mixed
- handle() : void
- keepMonitorOnSuccess() : bool
- Weather to keep successful monitor models. This can be used if you only want to keep failed monitors for jobs that are frequently executed but worth to monitor. You are free to use the Laravel built-in failed job procedures.
- middleware() : array<int, object>
- Get the middleware the job should pass through.
- progressCooldown() : int
- The time in seconds to wait before a following queue progress update will be issued.
- queueData() : void
- Set Monitor data.
- queueProgress() : void
- Update progress.
- queueProgressChunk() : void
- Automatically update the current progress in each chunk iteration.
- deleteQueueMonitor() : void
- Delete Queue Monitor object.
- getLogger() : LoggerInterface
- getQueueMonitor() : QueueMonitor|null
- Return Queue Monitor Model.
- batchSaveSongs() : void
- findOrCreateAlbum() : Album|null
- getArtistIds() : array<string|int, mixed>
- getGenreIds() : array<string|int, mixed>
- getLogChannelAttribute() : LogChannel|null
- getLyric() : string|null
- isCoverJobQueued() : bool
- isQueueProgressOnCooldown() : bool
- Check if the monitor should skip writing the progress to database avoiding rapid update queries.
- isSongInBaseDirectory() : bool
- makeSongAttributes() : array<string|int, mixed>|null
- processFile() : void
- processFiles() : void
- processMetadata() : array<string|int, mixed>|null
- queueCoverJob() : void
- shouldInitializeLogger() : bool
Constants
ARTIST_SEPARATOR
public
mixed
ARTIST_SEPARATOR
= ';'
GENRE_SEPARATOR
public
mixed
GENRE_SEPARATOR
= ';'
BATCH_SIZE
private
mixed
BATCH_SIZE
= 50
Properties
$directory
private
string
$directory
$library
private
Library
$library
$logger
private
LoggerInterface
$logger
Attributes
- #[LogChannel]
- $channel: \App\Modules\Logging\Channel::Metadata
$loggerCache
private
array<string|int, mixed>
$loggerCache
= []
$progressCurrentChunk
Internal variable used for tracking chunking progress.
private
int
$progressCurrentChunk
= 0
$progressLastUpdated
The unix timestamp explaining the last time a progress has been written to database.
private
int|null
$progressLastUpdated
Methods
__construct()
public
__construct(string $directory, Library $library) : mixed
Parameters
- $directory : string
- $library : Library
handle()
public
handle() : void
Tags
keepMonitorOnSuccess()
Weather to keep successful monitor models. This can be used if you only want to keep failed monitors for jobs that are frequently executed but worth to monitor. You are free to use the Laravel built-in failed job procedures.
public
static keepMonitorOnSuccess() : bool
Return values
boolmiddleware()
Get the middleware the job should pass through.
public
middleware() : array<int, object>
Return values
array<int, object>progressCooldown()
The time in seconds to wait before a following queue progress update will be issued.
public
progressCooldown() : int
This is used to avoid writing many progress updates to the database. 0 = no delay.
Return values
intqueueData()
Set Monitor data.
public
queueData(array<string|int, mixed> $data[, bool $merge = false ]) : void
Parameters
- $data : array<string|int, mixed>
-
Custom data
- $merge : bool = false
-
Merge the data instead of overriding
queueProgress()
Update progress.
public
queueProgress(int $progress) : void
Parameters
- $progress : int
-
Progress as integer 0-100
queueProgressChunk()
Automatically update the current progress in each chunk iteration.
public
queueProgressChunk(int $collectionCount, int $perChunk) : void
Parameters
- $collectionCount : int
-
The total collection item amount
- $perChunk : int
-
The size of each chunk
deleteQueueMonitor()
Delete Queue Monitor object.
protected
deleteQueueMonitor() : void
getLogger()
protected
getLogger([string $propertyName = 'logger' ]) : LoggerInterface
Parameters
- $propertyName : string = 'logger'
Return values
LoggerInterfacegetQueueMonitor()
Return Queue Monitor Model.
protected
getQueueMonitor() : QueueMonitor|null
Return values
QueueMonitor|nullbatchSaveSongs()
private
batchSaveSongs(array<string|int, mixed> $songs) : void
Parameters
- $songs : array<string|int, mixed>
findOrCreateAlbum()
private
findOrCreateAlbum(string $directoryName[, string|null $albumTitle = null ][, int|null $year = null ]) : Album|null
Parameters
- $directoryName : string
- $albumTitle : string|null = null
- $year : int|null = null
Return values
Album|nullgetArtistIds()
private
getArtistIds(array<string|int, mixed> $artists) : array<string|int, mixed>
Parameters
- $artists : array<string|int, mixed>
Return values
array<string|int, mixed>getGenreIds()
private
getGenreIds(array<string|int, mixed> $genres) : array<string|int, mixed>
Parameters
- $genres : array<string|int, mixed>
Return values
array<string|int, mixed>getLogChannelAttribute()
private
getLogChannelAttribute(ReflectionProperty $property) : LogChannel|null
Parameters
- $property : ReflectionProperty
Return values
LogChannel|nullgetLyric()
private
getLyric(SplFileInfo $file) : string|null
Parameters
- $file : SplFileInfo
Return values
string|nullisCoverJobQueued()
private
isCoverJobQueued(Album $album, array<string|int, mixed> $coverJobs) : bool
Parameters
- $album : Album
- $coverJobs : array<string|int, mixed>
Return values
boolisQueueProgressOnCooldown()
Check if the monitor should skip writing the progress to database avoiding rapid update queries.
private
isQueueProgressOnCooldown(int $progress) : bool
The progress values 0, 25, 50, 75 and 100 will always be written.
Parameters
- $progress : int
Return values
boolisSongInBaseDirectory()
private
isSongInBaseDirectory(string $path) : bool
Parameters
- $path : string
Return values
boolmakeSongAttributes()
private
makeSongAttributes(MediaMeta $mediaMeta, SplFileInfo $file, string $hash, string|null $lyric) : array<string|int, mixed>|null
Parameters
- $mediaMeta : MediaMeta
- $file : SplFileInfo
- $hash : string
- $lyric : string|null
Return values
array<string|int, mixed>|nullprocessFile()
private
processFile(MediaMeta $mediaMeta, SplFileInfo $file, array<string|int, mixed> &$songs, array<string|int, mixed> &$coverJobs) : void
Parameters
- $mediaMeta : MediaMeta
- $file : SplFileInfo
- $songs : array<string|int, mixed>
- $coverJobs : array<string|int, mixed>
processFiles()
private
processFiles(LazyCollection $files) : void
Parameters
- $files : LazyCollection
processMetadata()
private
processMetadata(MediaMeta $mediaMeta, string $filePath, string $hash, SplFileInfo $file, array<string|int, mixed> &$coverJobs) : array<string|int, mixed>|null
Parameters
- $mediaMeta : MediaMeta
- $filePath : string
- $hash : string
- $file : SplFileInfo
- $coverJobs : array<string|int, mixed>
Return values
array<string|int, mixed>|nullqueueCoverJob()
private
queueCoverJob(Album $album, array<string|int, mixed> &$coverJobs) : void
Parameters
- $album : Album
- $coverJobs : array<string|int, mixed>
shouldInitializeLogger()
private
shouldInitializeLogger(ReflectionProperty $property) : bool
Parameters
- $property : ReflectionProperty