fix: 修复 SFTP 格式化进度可能报错的问题

This commit is contained in:
hstyi
2025-01-10 12:31:45 +08:00
committed by hstyi
parent 5733b5f485
commit 9d4562e7e3
2 changed files with 15 additions and 1 deletions

View File

@@ -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) "-"

View 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) }
}
}