diff --git a/torrent/commonMain/TorrentDownloadSessionImpl.kt b/torrent/commonMain/TorrentDownloadSessionImpl.kt index 1f31bfa1a..5c9b1dfb1 100644 --- a/torrent/commonMain/TorrentDownloadSessionImpl.kt +++ b/torrent/commonMain/TorrentDownloadSessionImpl.kt @@ -72,7 +72,7 @@ internal class TorrentDownloadSessionImpl( * The directory may contain multiple files, or a single file. * The files are not guaranteed to be present at the moment when this function returns. */ - private val saveDirectory: File, + override val saveDirectory: File, private val onClose: suspend (TorrentDownloadSessionImpl) -> Unit, private val isDebug: Boolean, parentCoroutineContext: CoroutineContext = EmptyCoroutineContext, @@ -332,6 +332,7 @@ internal class TorrentDownloadSessionImpl( private val hashMd5 by lazy { scope.async { + stats.awaitFinished() withContext(Dispatchers.IO) { hashFileMd5(resolveDownloadingFile()) } diff --git a/torrent/commonMain/TorrentFileEntry.kt b/torrent/commonMain/TorrentFileEntry.kt index 59365cc0f..e8eb8bbc2 100644 --- a/torrent/commonMain/TorrentFileEntry.kt +++ b/torrent/commonMain/TorrentFileEntry.kt @@ -40,7 +40,7 @@ public interface TorrentFileEntry { /** * Returns the hash if available, otherwise `null` */ - public fun getFileHashOrNull(): String? // TODO: 这个函数会在文件还没下载完成时也返回 + public fun getFileHashOrNull(): String? /** * 绝对路径. 挂起直到文件路径可用 (即有任意一个 piece 下载完成时)