Skip to content

Commit

Permalink
Fix song recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
asivery committed Sep 2, 2023
1 parent d5cdfb1 commit 1465599
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,19 @@ async function integrate(window: BrowserWindow) {
handleBadSectorResolve = null;
shouldAbortAtracDownload = false;

const enableHandleBadSector = allArgs[3].handleBadSector;
const enableShouldCancelImmediately = allArgs[3].handleBadSector;

allArgs[3] = {
...allArgs[3],
handleBadSector: allArgs[3].handleBadSector ? async (...args: any[]) => {
handleBadSector: async (...args: any[]) => {
window.webContents.send('_atracdl_callback_handleBadSector', ...args);
return await new Promise<"reload" | "abort" | "skip" | "yieldanyway">(res => handleBadSectorResolve = res);
} : undefined,
shouldCancelImmediately: allArgs[3].handleBadSector ? () => shouldAbortAtracDownload : undefined,
},
shouldCancelImmediately: () => shouldAbortAtracDownload,
};
if(!enableHandleBadSector) delete allArgs[3].handleBadSector;
if(!enableShouldCancelImmediately) delete allArgs[3].shouldCancelImmediately;
allArgs[2] = async (...args: any[]) =>
window.webContents.send('_callback', `_factory__exploitDownloadTrack_callback2`, ...args);

Expand Down
8 changes: 6 additions & 2 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ import { NetMDFactoryService } from './wmd/original/services/interfaces/netmd';
const handleBadSector = args[3].handleBadSector;
callbacks[`_factory__exploitDownloadTrack_callback2`] = args[2];

args[3].shouldCancelImmediately = shouldCancelImmediately ? { interprocessType: 'nestedFunction' } as any : null;
args[3].handleBadSector = handleBadSector ? { interprocessType: 'nestedFunction' } as any : null;
args[3].shouldCancelImmediately = { interprocessType: 'nestedFunction' } as any;
args[3].handleBadSector = { interprocessType: 'nestedFunction' } as any;

if(!shouldCancelImmediately) delete args[3].shouldCancelImmediately;
if(!handleBadSector) delete args[3].handleBadSector;

args[2] = { interprocessType: 'function' } as any;
if(shouldCancelImmediately){
interval = setInterval(() => {
Expand Down

0 comments on commit 1465599

Please sign in to comment.