Skip to content

Commit

Permalink
Merge pull request #6 from rombat/fix/path-separator
Browse files Browse the repository at this point in the history
fix: path separator
  • Loading branch information
rombat authored Jul 10, 2023
2 parents 07efe1f + 3c88bb0 commit 7ebf6ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions lib/handlers/MBNDSynchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ dayjs.extend(customParseFormat);
dayjs.extend(duration);
dayjs.extend(relativeTime);
const cliProgress = require('cli-progress');
const path = require('path');

const dbManager = require('./dbManager');
const path = require('path');

class MBNDSynchronizer {
constructor(options, action) {
Expand Down Expand Up @@ -197,14 +197,17 @@ class MBNDSynchronizer {
console.log('Processing tracks...');
const progressBar = options.verbose ? null : new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
progressBar?.start(musicBeeCollection.length, 0);

const sampleDbTrack = await Track.findOne();
const dbFolderSeparator = sampleDbTrack.path.substring(1).startsWith(':\\') ? '\\' : '/';
let tracksAnnotations = await Promise.all(
musicBeeCollection.map(track =>
limit(async () => {
progressBar?.increment();
const filePathArray = track.filePath.split('\\');
const filePathEnd = `${filePathArray.length >= 2 ? filePathArray[filePathArray.length - 2] : ''}/${track.folder}/${
track.filename
}`;
const filePathEnd = `${filePathArray.length >= 2 ? filePathArray[filePathArray.length - 2] : ''}${dbFolderSeparator}${
track.folder
}${dbFolderSeparator}${track.filename}`;

const foundTrack = await Track.findOne({
where: {
Expand Down Expand Up @@ -294,9 +297,9 @@ class MBNDSynchronizer {
console.warn(`${notFoundTracks.length} tracks not found`);
}

await this.albumsSync(albumsToUpdate);
await this.albumsSync();

await this.artistsSync(artistsToUpdate);
await this.artistsSync();
};

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "musicbee-navidrome-sync",
"version": "1.0.5",
"version": "1.0.6",
"description": "sync ratings and playcount from musicbee db to navidrome db",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 7ebf6ec

Please sign in to comment.