Skip to content

Commit

Permalink
ref #24 in progress
Browse files Browse the repository at this point in the history
do not call handler if cancel call were an internal call
  • Loading branch information
CharlesGrimont committed Dec 21, 2020
1 parent 4619293 commit b7d893e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "c8osdkjscore",
"version": "3.0.11-beta55",
"version": "3.0.11-beta56",
"description": "convertigo's sdk js core",
"main": "bundle/index.umd.js",
"module": "src/index.js",
Expand Down
3 changes: 3 additions & 0 deletions src/c8o/c8oManagerDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class C8oManagerDatabase {
}
rep.finished = false;
rep.canceled = false;
rep.manual_canceled = false;
rep.database.startAllReplications(rep.parameters, rep.listener, handler1, rep.id, this.mutexCreateReplication);
break;
case "push":
Expand All @@ -113,6 +114,7 @@ export class C8oManagerDatabase {
}
rep.finished = false;
rep.canceled = false;
rep.manual_canceled = false;
rep.database.startPushReplication(rep.parameters, rep.listener, handler2, rep.id, this.mutexCreateReplication);

break;
Expand All @@ -124,6 +126,7 @@ export class C8oManagerDatabase {
}
rep.canceled = false;
rep.finished = false;
rep.manual_canceled = false;
rep.database.startPullReplication(rep.parameters, rep.listener, handler3, rep.id, this.mutexCreateReplication);
break;
}
Expand Down
21 changes: 17 additions & 4 deletions src/c8o/fullSyncDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class C8oFullSyncDatabase {
*/
private syncFullSyncReplication: FullSyncReplication = new FullSyncReplication();

private manual_canceled = false;
private remotePouchHeader;
private _id;
private to_cancel = [];
Expand Down Expand Up @@ -353,7 +354,10 @@ export class C8oFullSyncDatabase {
if(mutex != undefined){
mutex.release();
}
handler();
if(!this.manual_canceled){
handler();
}

}
else if (continuous) {
rep.cancel();
Expand Down Expand Up @@ -435,7 +439,9 @@ export class C8oFullSyncDatabase {
mutex.release();
}
this.c8o.log._trace("Replication is finished, modifying its state");
handler();
if(!this.manual_canceled){
handler();
}
}
}).on("error", (err) => {
rep.cancel();
Expand Down Expand Up @@ -586,7 +592,9 @@ export class C8oFullSyncDatabase {
if(mutex != undefined){
mutex.release();
}
handler();
if(!this.manual_canceled){
handler();
}
}
if (continuous) {
rep.cancel();
Expand Down Expand Up @@ -640,7 +648,9 @@ export class C8oFullSyncDatabase {
mutex.release();
}
this.c8o.log._trace("Replication is finished, modifying its state");
handler();
if(!this.manual_canceled){
handler();
}
}
}).on("error", (err) => {
rep.cancel();
Expand Down Expand Up @@ -717,6 +727,7 @@ export class C8oFullSyncDatabase {
*/
public cancelPullReplication(): void {
if (this.pullFullSyncReplication.replication != undefined) {
this.manual_canceled = true;
this.pullFullSyncReplication.replication.cancel();
}
}
Expand All @@ -726,6 +737,7 @@ export class C8oFullSyncDatabase {
*/
public cancelPushReplication(): void {
if (this.pushFullSyncReplication.replication != undefined) {
this.manual_canceled = true;
this.pushFullSyncReplication.replication.cancel();
}
}
Expand All @@ -735,6 +747,7 @@ export class C8oFullSyncDatabase {
*/
public cancelSyncReplication(): void {
if (this.syncFullSyncReplication.replication != undefined) {
this.manual_canceled = true;
this.syncFullSyncReplication.replication.cancel();
}
}
Expand Down

0 comments on commit b7d893e

Please sign in to comment.