mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-15 18:02:58 +08:00
chore: sftp failed message
This commit is contained in:
@@ -58,6 +58,7 @@ class Transport(
|
||||
|
||||
companion object {
|
||||
val idGenerator = AtomicLong(0)
|
||||
private val exception = RuntimeException("Nothing")
|
||||
private val log = LoggerFactory.getLogger(Transport::class.java)
|
||||
private val isPreserveModificationTime get() = Database.getDatabase().sftp.preserveModificationTime
|
||||
}
|
||||
@@ -110,6 +111,11 @@ class Transport(
|
||||
var status: TransportStatus = TransportStatus.Ready
|
||||
private set
|
||||
|
||||
/**
|
||||
* 失败异常
|
||||
*/
|
||||
var exception: Throwable = Transport.exception
|
||||
|
||||
|
||||
fun scanned() {
|
||||
scanned.compareAndSet(false, true)
|
||||
@@ -155,6 +161,7 @@ class Transport(
|
||||
log.warn("Directory ${target.name} already exists")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
exception = e
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.swing.Swing
|
||||
import okio.withLock
|
||||
import org.apache.commons.lang3.ArrayUtils
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils
|
||||
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode
|
||||
import org.jdesktop.swingx.treetable.DefaultTreeTableModel
|
||||
import org.jdesktop.swingx.treetable.MutableTreeTableNode
|
||||
@@ -291,6 +292,10 @@ class TransportTableModel(private val coroutineScope: CoroutineScope) :
|
||||
changeStatus(transport, TransportStatus.Done)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
// 记录异常
|
||||
transport.exception = ExceptionUtils.getRootCause(e)
|
||||
|
||||
if (e is TransportStatusException) {
|
||||
if (log.isWarnEnabled) {
|
||||
log.warn("{}: {}", transport.source.name, e.message)
|
||||
|
||||
@@ -21,7 +21,7 @@ class TransportTreeTableNode(transport: Transport) : DefaultMutableTreeTableNode
|
||||
|
||||
return when (column) {
|
||||
TransportTableModel.COLUMN_NAME -> PathUtils.getFileNameString(transport.source)
|
||||
TransportTableModel.COLUMN_STATUS -> formatStatus(transport.status)
|
||||
TransportTableModel.COLUMN_STATUS -> formatStatus(transport)
|
||||
TransportTableModel.COLUMN_SIZE -> size()
|
||||
TransportTableModel.COLUMN_SPEED -> if (isProcessing) formatBytes(speed) + "/s" else "-"
|
||||
TransportTableModel.COLUMN_ESTIMATED_TIME -> if (isProcessing) formatSeconds(estimatedTime) else "-"
|
||||
@@ -39,12 +39,12 @@ class TransportTreeTableNode(transport: Transport) : DefaultMutableTreeTableNode
|
||||
return path.toUri().scheme + ":" + path.absolutePathString()
|
||||
}
|
||||
|
||||
private fun formatStatus(status: TransportStatus): String {
|
||||
return when (status) {
|
||||
private fun formatStatus(transport: Transport): String {
|
||||
return when (transport.status) {
|
||||
TransportStatus.Processing -> I18n.getString("termora.transport.sftp.status.transporting")
|
||||
TransportStatus.Ready -> I18n.getString("termora.transport.sftp.status.waiting")
|
||||
TransportStatus.Done -> I18n.getString("termora.transport.sftp.status.done")
|
||||
TransportStatus.Failed -> I18n.getString("termora.transport.sftp.status.failed")
|
||||
TransportStatus.Failed -> I18n.getString("termora.transport.sftp.status.failed") + ": " + transport.exception.message
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user