chore: stop listening if the file does not exist (#230)

This commit is contained in:
hstyi
2025-02-14 15:36:26 +08:00
committed by GitHub
parent ea9c0f1225
commit 4e12c32566

View File

@@ -668,9 +668,15 @@ 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
withContext(Dispatchers.Swing) {
// upload // upload
transportManager.addTransport( transportManager.addTransport(
transport = FileTransport( transport = FileTransport(
@@ -682,12 +688,15 @@ class 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)
} }
} }