mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
fix: 修复 SFTP 格式化进度可能报错的问题
This commit is contained in:
@@ -81,7 +81,7 @@ class FileTransportTableModel(transportManager: TransportManager) : DefaultTable
|
||||
COLUMN_STATUS -> formatStatus(transport.state)
|
||||
|
||||
// 如果进度已经完成但是状态还是传输中,那么进度显示:99%
|
||||
COLUMN_PROGRESS -> String.format("%.0f%%", if (progress >= 100.0 && isTransporting) 99 else progress)
|
||||
COLUMN_PROGRESS -> String.format("%.0f%%", if (progress >= 100.0 && isTransporting) 99.0 else progress)
|
||||
|
||||
// 大小
|
||||
COLUMN_SIZE -> if (transport.size < 0) "-"
|
||||
|
||||
14
src/test/kotlin/app/termora/StringFormatTest.kt
Normal file
14
src/test/kotlin/app/termora/StringFormatTest.kt
Normal file
@@ -0,0 +1,14 @@
|
||||
package app.termora
|
||||
|
||||
import org.junit.jupiter.api.assertDoesNotThrow
|
||||
import java.util.*
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
class StringFormatTest {
|
||||
@Test
|
||||
fun test() {
|
||||
assertFailsWith(IllegalFormatConversionException::class) { String.format("%.0f%%", 99) }
|
||||
assertDoesNotThrow { String.format("%.0f%%", 99.0) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user