diff --git a/src/main/kotlin/app/termora/transport/FileSystemPanel.kt b/src/main/kotlin/app/termora/transport/FileSystemPanel.kt index 8901f22..c82e69f 100644 --- a/src/main/kotlin/app/termora/transport/FileSystemPanel.kt +++ b/src/main/kotlin/app/termora/transport/FileSystemPanel.kt @@ -668,26 +668,35 @@ class FileSystemPanel( coroutineScope.launch(Dispatchers.IO) { while (coroutineScope.isActive) { try { + + if (!Files.exists(localPath)) { + break + } + val nowModifiedTime = localPath.getLastModifiedTime().toMillis() if (nowModifiedTime != lastModifiedTime) { lastModifiedTime = nowModifiedTime - // upload - transportManager.addTransport( - transport = FileTransport( - name = PathUtils.getFileNameString(localPath.fileName), - source = localPath, - target = source, - sourceHolder = this@FileSystemPanel, - targetHolder = this@FileSystemPanel, + withContext(Dispatchers.Swing) { + // upload + transportManager.addTransport( + transport = FileTransport( + name = PathUtils.getFileNameString(localPath.fileName), + source = localPath, + target = source, + sourceHolder = this@FileSystemPanel, + targetHolder = this@FileSystemPanel, + ) ) - ) + } } + } catch (e: Exception) { if (log.isErrorEnabled) { log.error(e.message, e) } break } + delay(250.milliseconds) } }