Skip to content

Commit 48a70e2

Browse files
committed
Fixes and tweaks to backups service
1 parent bc8d2c4 commit 48a70e2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/sys/backup/SysBackupService.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,17 @@ public ActionResult onInvoke(DSInfo action, ActionInvocation invocation) {
6868
}
6969

7070
@Override
71-
public void onSet(DSInfo info, DSIValue value) {
72-
super.onSet(info, value);
71+
public void onChildChanged(DSInfo info) {
72+
super.onChildChanged(info);
7373
if (info == interval) {
74+
DSIValue value = info.getValue();
7475
synchronized (lock) {
7576
if (nextSave != null) {
7677
long newNextRun = (value.toElement().toLong() * 60000) + System.currentTimeMillis();
7778
long scheduledNextRun = nextSave.nextRun();
7879
if (newNextRun < scheduledNextRun) {
7980
nextSave.cancel();
80-
DSRuntime.runAt(this, newNextRun);
81+
nextSave = DSRuntime.runAt(this, newNextRun);
8182
}
8283
}
8384
}
@@ -215,5 +216,14 @@ public void run() {
215216
nextSave = DSRuntime.runDelayed(this, saveInterval);
216217
}
217218
}
219+
220+
@Override
221+
public void onStopped() {
222+
if (nextSave != null) {
223+
nextSave.cancel();
224+
nextSave = null;
225+
}
226+
save();
227+
}
218228

219229
}

dslink-v2/src/main/java/org/iot/dsa/dslink/DSLink.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ public static DSLink load(DSLinkConfig config) {
189189
} catch (Exception x) {
190190
DSException.throwRuntime(x);
191191
}
192-
// ret.save();
193192
}
194193
return ret;
195194
}
@@ -258,7 +257,6 @@ public void run() {
258257
stop();
259258
DSException.throwRuntime(x);
260259
}
261-
// save();
262260
LogManager.getLogManager().reset();
263261
Logger logger = Logger.getLogger("");
264262
for (Handler h : logger.getLogger("").getHandlers()) {

0 commit comments

Comments
 (0)