Skip to content

Commit 03ecd72

Browse files
committed
fix: songs from external collections are treated as internal
fixes #24
1 parent 687aebd commit 03ecd72

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

src/engine/1.6/engine-db-1_6.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class EngineDB_1_6 extends EngineDB {
9595
trackId: track.id,
9696
trackIdInOriginDatabase: track.id,
9797
trackNumber: i + 1,
98-
databaseUuid: this.databaseUuid,
98+
databaseUuid: this.uuid,
9999
})),
100100
);
101101
}
@@ -107,7 +107,11 @@ export class EngineDB_1_6 extends EngineDB {
107107
async getTracks(): Promise<publicSchema.Track[]> {
108108
const tracks = await this.getTracksInternal();
109109

110-
return tracks.map(track => ({ ...track, ...track.meta }));
110+
return tracks.map(track => ({
111+
...track,
112+
...track.meta,
113+
isBeatGridLocked: !!track.isBeatGridLocked,
114+
}));
111115
}
112116

113117
private async getTracksInternal(): Promise<schema.TrackWithMeta[]> {
@@ -124,7 +128,8 @@ export class EngineDB_1_6 extends EngineDB {
124128
'trackType',
125129
'year',
126130
])
127-
.whereNotNull('path');
131+
.whereNotNull('path')
132+
.andWhere('isExternalTrack', 0);
128133
const textMetas = await this.table('MetaData').select('*');
129134
const textMetaMap = groupBy(textMetas, x => x.id);
130135
const intMetas = await this.table('MetaDataInteger').select('*');

src/engine/1.6/schema-1_6.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export interface Track {
7171
bitrate: number;
7272
bpmAnalyzed: number;
7373
filename: string;
74-
isBeatGridLocked: boolean;
75-
isExternalTrack: boolean;
74+
isBeatGridLocked: IntBoolean;
75+
isExternalTrack: IntBoolean;
7676
length: number;
7777
path: string;
7878
trackType: TrackType;

src/engine/2.0/engine-db-2_0.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class EngineDB_2_0 extends EngineDB {
107107
? 0
108108
: lastEntityId + 2 + i,
109109
membershipReference: 0,
110-
databaseUuid: this.databaseUuid,
110+
databaseUuid: this.uuid,
111111
})),
112112
);
113113
}
@@ -150,7 +150,8 @@ export class EngineDB_2_0 extends EngineDB {
150150
'title',
151151
'year',
152152
])
153-
.whereNotNull('path');
153+
.whereNotNull('path')
154+
.andWhere('originDatabaseUuid', this.uuid);
154155
}
155156

156157
async updateTrackPaths(tracks: publicSchema.Track[]) {

src/engine/engine-db.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ import { EngineVersion } from './version-detection';
88
export abstract class EngineDB {
99
protected readonly knex: Knex;
1010

11-
protected databaseUuid!: string;
11+
protected schemaInfo!: schema.Information;
1212

1313
abstract get version(): EngineVersion;
1414

15+
get uuid(): string {
16+
return this.schemaInfo.uuid;
17+
}
18+
1519
protected constructor(private readonly dbPath: string) {
1620
this.knex = knex({
1721
client: 'sqlite3',
@@ -22,9 +26,7 @@ export abstract class EngineDB {
2226

2327
protected async init() {
2428
await this.backup();
25-
const { uuid } = await this.getSchemaInfo();
26-
27-
this.databaseUuid = uuid;
29+
this.schemaInfo = await this.getSchemaInfo();
2830
}
2931

3032
async disconnect() {

0 commit comments

Comments
 (0)