Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
[RAINCATCH-623] Use fh-sync clearCache on logout (#120)
Browse files Browse the repository at this point in the history
* add clearCache

* address pr comments and update unit test
  • Loading branch information
JameelB committed Sep 18, 2017
1 parent f8343fe commit 3082354
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions client/datasync-client/src/DataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class DataManager {
syncApi.stopSync(self.datasetId, function() {
resolve();
}, function(error) {
reject(new Error(error));
return reject(new Error(error));
});
});
}
Expand Down Expand Up @@ -179,8 +179,7 @@ export class DataManager {
const options = _.defaults(userOptions, defaultOptions);
function forceSyncThenStop(pendingUpdateQueueSize) {
if (pendingUpdateQueueSize === 0) {
self.stop().then(Bluebird.resolve);
return;
return Bluebird.resolve(self.stop());
}
// Steps: force sync, wait, check if results were synced back, stop server
return self.forceSync()
Expand Down Expand Up @@ -210,6 +209,13 @@ export class DataManager {
});
}

/**
* Clears the cache for the dataset
*/
public clearCache() {
return syncApi.clearCache(this.datasetId);
}

/**
* Get the current number of pending sync requests for this data set.
*/
Expand Down
3 changes: 2 additions & 1 deletion client/datasync-client/test/DataManagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ describe('Data Manager', function() {
const results = [];
const mock$fh = {
forceSync: sinon.stub().callsArgWith(1),
getPending: sinon.stub().callsArgWith(1, results)
getPending: sinon.stub().callsArgWith(1, results),
stopSync: sinon.stub().callsArgWith(1)
};

const DataManager = proxyquire.noCallThru().load('../src/DataManager', {
Expand Down

0 comments on commit 3082354

Please sign in to comment.