@@ -27,12 +27,12 @@ class PocketWalService {
2727 final directory = await getApplicationDocumentsDirectory ();
2828 final cleanDeviceId = device.id.replaceAll (RegExp (r'[^a-zA-Z0-9]' ), "" ).toLowerCase ();
2929 final mp3Filename = 'pocket_${cleanDeviceId }_$timerStart .mp3' ;
30- final filePath = '${directory .path }/$mp3Filename ' ;
30+ final fullPath = '${directory .path }/$mp3Filename ' ;
3131
32- final file = File (filePath );
32+ final file = File (fullPath );
3333 await file.writeAsBytes (mp3Data);
3434
35- debugPrint ('Saved Pocket MP3: $filePath ' );
35+ debugPrint ('Saved Pocket MP3: $fullPath ' );
3636
3737 // Create WAL object
3838 // Note: We use opus codec as a placeholder since the backend will handle MP3
@@ -44,8 +44,8 @@ class PocketWalService {
4444 sampleRate: 16000 , // Standard sample rate
4545 channel: 1 , // Mono
4646 status: WalStatus .miss, // Mark as missing/ready to sync
47- storage: WalStorage .sdcard , // Mark as external source (like SD card)
48- filePath: filePath,
47+ storage: WalStorage .disk , // Store as phone storage (not SD card)
48+ filePath: mp3Filename, // Store only filename, not full path
4949 device: device.id,
5050 deviceModel: 'Pocket' ,
5151 storageOffset: 0 ,
@@ -85,26 +85,32 @@ class PocketWalService {
8585
8686 /// Add WAL files to the WAL service for syncing
8787 static Future <void > addWalsToService (List <Wal > wals) async {
88+ debugPrint ('addWalsToService: Adding ${wals .length } WALs' );
89+
8890 // Load existing WALs
8991 final existingWals = await WalFileManager .loadWals ();
92+ debugPrint ('addWalsToService: Loaded ${existingWals .length } existing WALs' );
9093
9194 // Add new WALs (avoid duplicates by checking timerStart and device)
9295 final updatedWals = List <Wal >.from (existingWals);
96+ int addedCount = 0 ;
9397 for (final wal in wals) {
9498 final isDuplicate = existingWals.any (
9599 (existing) => existing.device == wal.device && existing.timerStart == wal.timerStart,
96100 );
97101 if (! isDuplicate) {
98102 updatedWals.add (wal);
99- debugPrint ('Added Pocket WAL to service: ${wal .id }' );
103+ addedCount++ ;
104+ debugPrint ('Added Pocket WAL: device=${wal .device }, timerStart=${wal .timerStart }, filePath=${wal .filePath }' );
100105 } else {
101- debugPrint ('Skipped duplicate Pocket WAL: ${wal .id }' );
106+ debugPrint ('Skipped duplicate Pocket WAL: device= ${wal .device }, timerStart=${ wal . timerStart }' );
102107 }
103108 }
104109
105110 // Save updated WALs
111+ debugPrint ('addWalsToService: Saving ${updatedWals .length } total WALs (added $addedCount new)' );
106112 await WalFileManager .saveWals (updatedWals);
107- debugPrint ('Saved ${ wals . length } Pocket WALs to service ' );
113+ debugPrint ('addWalsToService: Successfully saved WALs' );
108114 }
109115
110116 /// Parse timestamp from Pocket recording format (YYYYMMDDHHMMSS)
0 commit comments