Skip to content

Commit

Permalink
修复 getFileHashOrNull 即使文件没下载完成也尝试 hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Apr 24, 2024
1 parent 911c936 commit f6e12e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion torrent/commonMain/TorrentDownloadSessionImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -332,6 +332,7 @@ internal class TorrentDownloadSessionImpl(

private val hashMd5 by lazy {
scope.async {
stats.awaitFinished()
withContext(Dispatchers.IO) {
hashFileMd5(resolveDownloadingFile())
}
Expand Down
2 changes: 1 addition & 1 deletion torrent/commonMain/TorrentFileEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface TorrentFileEntry {
/**
* Returns the hash if available, otherwise `null`
*/
public fun getFileHashOrNull(): String? // TODO: 这个函数会在文件还没下载完成时也返回
public fun getFileHashOrNull(): String?

/**
* 绝对路径. 挂起直到文件路径可用 (即有任意一个 piece 下载完成时)
Expand Down

0 comments on commit f6e12e3

Please sign in to comment.