This commit is contained in:
Eric85710 2026-06-29 14:12:34 +08:00
parent 7e8f361212
commit 00eb15613b

View file

@ -459,7 +459,6 @@ class ChatRoomsRepository @Inject constructor(
.build() .build()
val response = httpClient.newCall(request).execute() val response = httpClient.newCall(request).execute()
Log.d("ChatDebug", "📥 收到回應, HTTP Status Code: ${response.code}")
if (!response.isSuccessful) { if (!response.isSuccessful) {
val errorBody = response.body?.string() ?: "無回應內容" val errorBody = response.body?.string() ?: "無回應內容"
@ -477,7 +476,6 @@ class ChatRoomsRepository @Inject constructor(
// 🎯 修正後的寫法:直接存入手機系統的公共 Download 資料夾 // 🎯 修正後的寫法:直接存入手機系統的公共 Download 資料夾
val targetDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) val targetDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
val targetFile = File(targetDirectory, fileName) val targetFile = File(targetDirectory, fileName)
Log.d("ChatDebug", "📊 檔案總大小: $totalBytes bytes, 儲存路徑: ${targetFile.absolutePath}")
var bytesCopied = 0L var bytesCopied = 0L
val buffer = ByteArray(DEFAULT_BUFFER_SIZE) val buffer = ByteArray(DEFAULT_BUFFER_SIZE)
@ -499,11 +497,9 @@ class ChatRoomsRepository @Inject constructor(
} }
} }
Log.d("ChatDebug", "✅ 檔案寫入完成! 實際寫入: $bytesCopied bytes")
emit(Result.success(1.0f)) emit(Result.success(1.0f))
} catch (e: Exception) { } catch (e: Exception) {
Log.e("ChatDebug", "💥 Repository 下載過程中發生異常", e)
emit(Result.failure(e)) emit(Result.failure(e))
} }
}.flowOn(Dispatchers.IO) }.flowOn(Dispatchers.IO)