mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 10:22:58 +08:00
chore: stop listening if the file does not exist (#230)
This commit is contained in:
@@ -668,26 +668,35 @@ class FileSystemPanel(
|
|||||||
coroutineScope.launch(Dispatchers.IO) {
|
coroutineScope.launch(Dispatchers.IO) {
|
||||||
while (coroutineScope.isActive) {
|
while (coroutineScope.isActive) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
if (!Files.exists(localPath)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
val nowModifiedTime = localPath.getLastModifiedTime().toMillis()
|
val nowModifiedTime = localPath.getLastModifiedTime().toMillis()
|
||||||
if (nowModifiedTime != lastModifiedTime) {
|
if (nowModifiedTime != lastModifiedTime) {
|
||||||
lastModifiedTime = nowModifiedTime
|
lastModifiedTime = nowModifiedTime
|
||||||
// upload
|
withContext(Dispatchers.Swing) {
|
||||||
transportManager.addTransport(
|
// upload
|
||||||
transport = FileTransport(
|
transportManager.addTransport(
|
||||||
name = PathUtils.getFileNameString(localPath.fileName),
|
transport = FileTransport(
|
||||||
source = localPath,
|
name = PathUtils.getFileNameString(localPath.fileName),
|
||||||
target = source,
|
source = localPath,
|
||||||
sourceHolder = this@FileSystemPanel,
|
target = source,
|
||||||
targetHolder = this@FileSystemPanel,
|
sourceHolder = this@FileSystemPanel,
|
||||||
|
targetHolder = this@FileSystemPanel,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
if (log.isErrorEnabled) {
|
if (log.isErrorEnabled) {
|
||||||
log.error(e.message, e)
|
log.error(e.message, e)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(250.milliseconds)
|
delay(250.milliseconds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user