removed md5 sum check again, performance degraded
This commit is contained in:
parent
e8e79e58f2
commit
13f5ef0ede
2 changed files with 3 additions and 39 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
Loading…
Reference in a new issue