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