diff --git a/classes/Queue.js b/classes/Queue.js index 2ea4b04..71d1727 100644 --- a/classes/Queue.js +++ b/classes/Queue.js @@ -1,5 +1,4 @@ const metadata = require('../libs/metadata.js'); -const { md5 } = require('../libs/util.js'); const { extname } = require('path'); class Queue { @@ -74,14 +73,10 @@ class Queue { if (file === undefined) { return; } - const hash = await md5(file); - if (! await this.fileChanged(file, hash)) { - return; - } const tags = await metadata.parseFile(file); const artist = await this.addArtist(tags); const album = await this.addAlbum(tags); - const track = await this.addTrack(tags, file, hash); + const track = await this.addTrack(tags, file); this.linkTrackToArtist(track, artist); this.linkTrackToAlbum(track, album); this.linkAlbumToArtist(album, artist); @@ -106,29 +101,6 @@ class Queue { } } - async fileChanged(file, hash) { - if (file === undefined) { - return; - } - const where = { - file: file - }; - if (hash === undefined) { - hash = await md5(file); - } - if (hash !== undefined) { - where.hash = hash; - } - try { - const element = await database.models.Track.findOne({ - where: where - }); - return element?.id === undefined; - } catch (err) { - logger.error('error finding database entry for file \'' + file + '\' with md5 sum \'' + hash + '\' > ' + err); - } - } - async addArtist(tags) { if (tags?.common?.artist === undefined && tags?.common?.artists === undefined) { return; @@ -173,20 +145,13 @@ class Queue { } } - async addTrack(tags, file, hash) { + async addTrack(tags, file) { if (tags?.common?.title === undefined || file === undefined) { return; } - let timestamp = new Date(); const where = { file: file }; - if (hash === undefined) { - hash = await md5(file); - } - if (hash !== undefined) { - where.hash = hash; - } if (tags?.common?.title !== undefined) { where.title = tags.common.title; } diff --git a/models/Track.js b/models/Track.js index 6d737ba..0865111 100644 --- a/models/Track.js +++ b/models/Track.js @@ -9,8 +9,7 @@ const Track = database.connection.define("track", { diskof: DataTypes.INTEGER, trackno: DataTypes.INTEGER, trackof: DataTypes.INTEGER, - file: DataTypes.TEXT, - hash: DataTypes.TEXT + file: DataTypes.TEXT }); module.exports = Track; \ No newline at end of file