mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: transfer shows error message
This commit is contained in:
@@ -379,7 +379,11 @@ class TransferTableModel(private val coroutineScope: CoroutineScope) :
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
} else if (canTransfer(node)) {
|
} else if (canTransfer(node)) {
|
||||||
|
if (continueTransfer(node, false)) {
|
||||||
doTransfer(node)
|
doTransfer(node)
|
||||||
|
} else {
|
||||||
|
changeState(node, State.Failed)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lock.withLock { condition.signalAll() }
|
lock.withLock { condition.signalAll() }
|
||||||
} catch (_: CancellationException) {
|
} catch (_: CancellationException) {
|
||||||
@@ -407,8 +411,9 @@ class TransferTableModel(private val coroutineScope: CoroutineScope) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
node.tryChangeState(State.Failed)
|
tryChangeState(node, State.Failed)
|
||||||
if (e !is UserCanceledException) {
|
if (e !is UserCanceledException) {
|
||||||
|
node.setException(e)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -444,6 +449,12 @@ class TransferTableModel(private val coroutineScope: CoroutineScope) :
|
|||||||
fireTransferChanged(node)
|
fireTransferChanged(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun tryChangeState(node: TransferTreeTableNode, state: State) {
|
||||||
|
if (node.tryChangeState(state)) {
|
||||||
|
fireTransferChanged(node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun removeCompleted(node: TransferTreeTableNode) {
|
private fun removeCompleted(node: TransferTreeTableNode) {
|
||||||
|
|
||||||
if (node == getRoot()) return
|
if (node == getRoot()) return
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import app.termora.formatBytes
|
|||||||
import app.termora.formatSeconds
|
import app.termora.formatSeconds
|
||||||
import app.termora.transfer.TransferTableModel.Companion.COLUMN_COUNT
|
import app.termora.transfer.TransferTableModel.Companion.COLUMN_COUNT
|
||||||
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.lang3.StringUtils
|
||||||
|
import org.apache.commons.lang3.exception.ExceptionUtils
|
||||||
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode
|
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode
|
||||||
import java.nio.file.FileSystems
|
import java.nio.file.FileSystems
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
@@ -43,6 +44,8 @@ class TransferTreeTableNode(transfer: Transfer) : DefaultMutableTreeTableNode(tr
|
|||||||
*/
|
*/
|
||||||
private var state = State.Ready
|
private var state = State.Ready
|
||||||
|
|
||||||
|
private var exception: Exception? = null
|
||||||
|
|
||||||
|
|
||||||
override fun getColumnCount(): Int {
|
override fun getColumnCount(): Int {
|
||||||
return COLUMN_COUNT
|
return COLUMN_COUNT
|
||||||
@@ -96,6 +99,14 @@ class TransferTreeTableNode(transfer: Transfer) : DefaultMutableTreeTableNode(tr
|
|||||||
return I18n.getString("termora.transport.sftp.status.deleting")
|
return I18n.getString("termora.transport.sftp.status.deleting")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state == State.Failed) {
|
||||||
|
val e = exception
|
||||||
|
if (e != null) {
|
||||||
|
val message = ExceptionUtils.getRootCauseMessage(e)
|
||||||
|
return "${I18n.getString("termora.transport.sftp.status.failed")}: $message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return when (state) {
|
return when (state) {
|
||||||
State.Processing -> I18n.getString("termora.transport.sftp.status.transporting")
|
State.Processing -> I18n.getString("termora.transport.sftp.status.transporting")
|
||||||
State.Ready -> I18n.getString("termora.transport.sftp.status.waiting")
|
State.Ready -> I18n.getString("termora.transport.sftp.status.waiting")
|
||||||
@@ -130,6 +141,9 @@ class TransferTreeTableNode(transfer: Transfer) : DefaultMutableTreeTableNode(tr
|
|||||||
this.state = state
|
this.state = state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setException(e: Exception) {
|
||||||
|
this.exception = e
|
||||||
|
}
|
||||||
|
|
||||||
fun tryChangeState(state: State): Boolean {
|
fun tryChangeState(state: State): Boolean {
|
||||||
if (this.state == State.Done || this.state == State.Failed) {
|
if (this.state == State.Done || this.state == State.Failed) {
|
||||||
|
|||||||
Reference in New Issue
Block a user