From a40b35a5a230b07d933844472ac55c702fce199b Mon Sep 17 00:00:00 2001 From: Greg Alexander Date: Wed, 17 Dec 2014 20:39:48 -0500 Subject: [PATCH] updater checks length as well as time, in case there are multiple modifications within the same second --- src/org/galexander/sshd/UpdaterThread.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/org/galexander/sshd/UpdaterThread.java b/src/org/galexander/sshd/UpdaterThread.java index 6ccf8a9..fc1328a 100644 --- a/src/org/galexander/sshd/UpdaterThread.java +++ b/src/org/galexander/sshd/UpdaterThread.java @@ -7,6 +7,7 @@ public class UpdaterThread extends Thread { public void run() { File f = new File(Prefs.get_path(), "dropbear.err"); long lastmod = 0; + long lastlen = 0; System.out.println("sshd: updater start"); while (true) { if (isInterrupted()) { @@ -17,15 +18,27 @@ System.out.println("sshd: updater interrupted"); System.out.println("sshd: activity stopped"); break; } - long l = f.lastModified(); - if (l != lastmod) { -System.out.println("sshd: updating"); + long mod = f.lastModified(); + long len = f.length(); + if (mod != lastmod) { +System.out.println("sshd: updating for time"); SimpleSSHD.curr.runOnUiThread(new Thread() { public void run() { SimpleSSHD.curr.update_log(); } }); - lastmod = l; + lastmod = mod; + lastlen = len; + } + if (len != lastlen) { +System.out.println("sshd: updating for len"); + SimpleSSHD.curr.runOnUiThread(new Thread() { + public void run() { + SimpleSSHD.curr.update_log(); + } + }); + lastmod = mod; + lastlen = len; } try { sleep(1000);