Working on scheduleCommit

This commit is contained in:
Jonathan Putney
2019-11-19 15:00:45 -05:00
parent e19e7d76fa
commit 74ac0d4c8c
5 changed files with 16 additions and 10 deletions
+8 -4
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -194,8 +194,8 @@ export default class BaseAPI {
// If we didn't have any errors while setting the data, go ahead and // If we didn't have any errors while setting the data, go ahead and
// schedule a commit, if autocommit is turned on // schedule a commit, if autocommit is turned on
if (String(this.lastErrorCode) === '0') { if (String(this.lastErrorCode) === '0') {
if (this.#settings.autocommit && this.#timeout === undefined) { if (this.settings.autocommit && !this.#timeout) {
this.scheduleCommit(this.#settings.autocommitSeconds * 1000); this.scheduleCommit(this.settings.autocommitSeconds * 1000);
} }
} }
@@ -899,6 +899,7 @@ export default class BaseAPI {
*/ */
scheduleCommit(when: number) { scheduleCommit(when: number) {
this.#timeout = new ScheduledCommit(this, when); this.#timeout = new ScheduledCommit(this, when);
this.apiLog('scheduleCommit', null, null, global_constants.LOG_LEVEL_DEBUG);
} }
/** /**
@@ -908,6 +909,7 @@ export default class BaseAPI {
if (this.#timeout) { if (this.#timeout) {
this.#timeout.cancel(); this.#timeout.cancel();
this.#timeout = null; this.#timeout = null;
this.apiLog('clearScheduledCommit', null, null, global_constants.LOG_LEVEL_DEBUG);
} }
} }
} }
+1 -1
View File
@@ -428,7 +428,7 @@ export class CMI extends BaseCMI {
* @param {string} suspend_data * @param {string} suspend_data
*/ */
set suspend_data(suspend_data) { set suspend_data(suspend_data) {
if (check2004ValidFormat(suspend_data, regex.CMIString64000)) { if (check2004ValidFormat(suspend_data, regex.CMIString64000, true)) {
this.#suspend_data = suspend_data; this.#suspend_data = suspend_data;
} }
} }