Skip to content

Commit

Permalink
fix opendb and other query being called together in case of db close
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwalguptaofficial committed Sep 19, 2023
1 parent 2f01f0b commit bf18bac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/main/connection_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@ export class ConnectionHelper {
this.isDbIdle_ = true;
break;
case API.CloseDb:
this.isDbIdle_ = true;
this.eventBus_.emit(EVENT.RequestQueueEmpty, []);
if (this.requestQueue_.length > 0) {
this.openDb_();
}
else {
this.isDbIdle_ = true;
this.eventBus_.emit(EVENT.RequestQueueEmpty, []);
this.openDb_(false);
}
break;
}
Expand All @@ -110,8 +108,8 @@ export class ConnectionHelper {
}
}

private openDb_() {
this.prcoessExecutionOfQry_({
private openDb_(execute = true) {
const request = {
name: API.OpenDb,
query: {
name: this.database.name,
Expand All @@ -123,7 +121,13 @@ export class ConnectionHelper {
onError: function (err) {
console.error(err);
}
}, 0);
};
if (execute) {
this.prcoessExecutionOfQry_(request, 0);
}
else {
this.requestQueue_.splice(0, 0, request);
}
}

private executeMiddleware_(input: WebWorkerRequest) {
Expand Down
2 changes: 1 addition & 1 deletion src/worker/query_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export class QueryManager {
this.util
).then((dbFromCache: DbMeta) => {
if (dbFromCache) {
dbFromCache.tables.forEach((tableFromCache, index) => {
dbFromCache.tables.forEach((tableFromCache) => {
const targetTable = dbMeta.tables.find(q => q.name === tableFromCache.name);
if (targetTable) {
for (const key in tableFromCache.autoIncColumnValue) {
Expand Down

0 comments on commit bf18bac

Please sign in to comment.