Files and Directory Tasks Manager¶
This module organizes the integration of uploaded content into the Music Directory.
FilesystemManager Class¶
- class musicdb.taskmanagement.filesystemmanager.FilesystemManager(config, database)[source]¶
This class manages all files and directories inside the MusicDB Music Directory. It can be used to scan for new files or find lost connections between database entries and files.
This class is derived from
musicdb.taskmanagement.taskmanager.TaskManager
.- Parameters
config –
MusicDBConfig
object holding the MusicDB Configurationdatabase – A
MusicDatabase
instance
- Raises
TypeError – When the arguments are not of the correct type.
- FindNewPaths()[source]¶
This method scans the file systems for new paths via
musicdb.mdbapi.music.MusicDBMusic.FindNewPaths()
. If a new path is a file, its checksum gets calculated so that the file can be compared to existing database entries.The returned dictionary has the following structure:
"artists"
,"albums"
,"songs"
,"videos"
each a list of further dictionariesThese dictionaries have a key
"path"
with paths relative to the Music DirectorySong and Video entries have a key
"checksum"
that contains the checksum of the files for comparing them with the database entries
- Returns
A dictionary with lists as described above
- InitiateFilesystemScan()[source]¶
This method initiates a file system scan. It sets the task state to
"startfsscan"
and the content type to"any"
.- Parameters
taskid (str) – ID of the task that performed the upload
targetpath (str) – Path relative to the music directory
- Returns
The task ID as string or
None
if something failed.- Raises
TypeError – When one of the parameters are of a wrong data type
ValueError – When one of the parameters has an unexpected value
- ScanFilesystem(task)[source]¶
This method scans the file system for lost and new paths. It does the following steps:
Check all database entries if the associated files and directories can be found via
musicdb.mdbapi.music.MusicDBMusic.FindLostPaths()
If not, collect their database entry
Find all new files and directories via
musicdb.mdbapi.music.MusicDBMusic.FindNewPaths()
Collect their path and check sum (this may take some time)
"newpaths"
"artists"
,"albums"
,"songs"
,"filteredsongs"
,"videos"
Each entry is a list of dictionaries
All dictionaries have the entry “path”
for “songs” and “videos” one entry is “checksum”
"lostpaths"
"artists"
,"albums"
,"songs"
,"videos"
Each entry is a list of database entries as dictionary
The found information are annotated to the task