@@ -34,6 +34,13 @@ export interface DownloadProgressEvent {
3434 magnetUri : string ; // The magnet URI being downloaded
3535}
3636
37+ export interface MetadataEvent {
38+ name : string ; // Torrent/file name
39+ size : number ; // Total size in bytes
40+ magnetUri : string ; // The magnet URI
41+ infoHash : string ; // The torrent info hash
42+ }
43+
3744export class FileClient extends EventEmitter implements IFileClient {
3845 private gunRegistry : GunRegistry ;
3946 private webTorrentClient : WebTorrent . Instance | null = null ;
@@ -319,6 +326,21 @@ export class FileClient extends EventEmitter implements IFileClient {
319326 return ;
320327 }
321328
329+ // Add metadata event emission
330+ torrent . on ( "metadata" , ( ) => {
331+ this . logger . debug ( `📋 Torrent metadata ready: ${ torrent ! . name } , Size: ${ torrent ! . length } bytes` ) ;
332+
333+ const metadataData : MetadataEvent = {
334+ name : torrent ! . name || 'Unknown' ,
335+ size : torrent ! . length ,
336+ magnetUri : magnetUri ,
337+ infoHash : torrent ! . infoHash || 'Unknown'
338+ } ;
339+
340+ // Emit the metadata event that external code can listen to
341+ this . emit ( 'metadata' , metadataData ) ;
342+ } ) ;
343+
322344 torrent . on ( "ready" , ( ) => {
323345 this . logger . debug (
324346 `✅ Torrent ready! File: ${ torrent ! . name } , Size: ${ torrent ! . length } bytes, Files: ${ torrent ! . files . length } `
@@ -410,7 +432,7 @@ export class FileClient extends EventEmitter implements IFileClient {
410432 torrent . on ( "download" , ( _bytes : number ) => {
411433 const progressData : DownloadProgressEvent = {
412434 downloaded : torrent ! . downloaded ,
413- downloadSpeed : torrent ! . downloadSpeed ,
435+ downloadSpeed : torrent ! . downloadSpeed * 100 ,
414436 progress : torrent ! . progress * 100 ,
415437 name : torrent ! . name || 'Unknown' ,
416438 magnetUri : magnetUri
0 commit comments