Skip to content

Commit

Permalink
Fix track association so it only errors if files found < files expect…
Browse files Browse the repository at this point in the history
…ed (#904)

* Only error if less files found

* Do we need this?
  • Loading branch information
dmanjunath committed Oct 9, 2020
1 parent 1872a0a commit c407cf8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions creator-node/src/routes/tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ module.exports = function (app) {
const existingTrackEntry = await models.Track.findOne({
where: {
cnodeUserUUID,
blockchainId: blockchainTrackId,
coverArtFileUUID
blockchainId: blockchainTrackId
},
order: [['clock', 'DESC']],
transaction
Expand Down Expand Up @@ -381,7 +380,8 @@ module.exports = function (app) {
transaction
})

if (trackFiles.length !== trackSegmentCIDs.length) {
if (trackFiles.length < trackSegmentCIDs.length) {
req.logger.error(`Did not find files for every track segment CID for user ${cnodeUserUUID} ${trackFiles} ${trackSegmentCIDs}`)
throw new Error('Did not find files for every track segment CID.')
}
const numAffectedRows = await models.File.update(
Expand All @@ -396,7 +396,8 @@ module.exports = function (app) {
transaction
}
)
if (parseInt(numAffectedRows, 10) !== trackSegmentCIDs.length) {
if (parseInt(numAffectedRows, 10) < trackSegmentCIDs.length) {
req.logger.error(`Failed to associate files for every track segment CID ${cnodeUserUUID} ${track.blockchainId} ${numAffectedRows} ${trackSegmentCIDs.length}`)
throw new Error('Failed to associate files for every track segment CID.')
}
} else { /** If track updated, ensure files exist with trackBlockchainId. */
Expand Down

0 comments on commit c407cf8

Please sign in to comment.