mirror of
https://github.com/markuryy/shark.git
synced 2025-12-13 12:01:01 +00:00
fix(dl): add progress events for tracks from new downloader
This commit is contained in:
@@ -31,6 +31,7 @@ export async function downloadTrack(
|
||||
retryCount: number = 0,
|
||||
decryptionTrackId?: string
|
||||
): Promise<string> {
|
||||
const { listen } = await import('@tauri-apps/api/event');
|
||||
// Generate paths
|
||||
const paths = generateTrackPath(track, musicFolder, format, false);
|
||||
|
||||
@@ -60,16 +61,28 @@ export async function downloadTrack(
|
||||
// Use the provided decryption track ID (for fallback tracks) or the original track ID
|
||||
const trackIdForDecryption = decryptionTrackId ? decryptionTrackId.toString() : track.id.toString();
|
||||
|
||||
// Download and decrypt in Rust backend (streaming, no memory accumulation)
|
||||
console.log('Downloading and decrypting track in Rust backend...');
|
||||
await invoke('download_and_decrypt_track', {
|
||||
url: downloadURL,
|
||||
trackId: trackIdForDecryption,
|
||||
outputPath: paths.tempPath,
|
||||
isEncrypted: isCrypted
|
||||
// Set up progress listener
|
||||
const unlisten = await listen<DownloadProgress>('download-progress', (event) => {
|
||||
if (onProgress) {
|
||||
onProgress(event.payload);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Download and decryption complete!');
|
||||
try {
|
||||
// Download and decrypt in Rust backend (streaming, no memory accumulation)
|
||||
console.log('Downloading and decrypting track in Rust backend...');
|
||||
await invoke('download_and_decrypt_track', {
|
||||
url: downloadURL,
|
||||
trackId: trackIdForDecryption,
|
||||
outputPath: paths.tempPath,
|
||||
isEncrypted: isCrypted
|
||||
});
|
||||
|
||||
console.log('Download and decryption complete!');
|
||||
} finally {
|
||||
// Clean up event listener
|
||||
unlisten();
|
||||
}
|
||||
|
||||
// Get user settings
|
||||
const appSettings = get(settings);
|
||||
|
||||
Reference in New Issue
Block a user