diff --git a/client/datasync-client/src/DataManager.ts b/client/datasync-client/src/DataManager.ts index ee02ba8..e3638e4 100644 --- a/client/datasync-client/src/DataManager.ts +++ b/client/datasync-client/src/DataManager.ts @@ -140,7 +140,7 @@ export class DataManager { syncApi.stopSync(self.datasetId, function() { resolve(); }, function(error) { - reject(new Error(error)); + return reject(new Error(error)); }); }); } @@ -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() @@ -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. */ diff --git a/client/datasync-client/test/DataManagerTest.ts b/client/datasync-client/test/DataManagerTest.ts index 82df3c7..ab71c22 100644 --- a/client/datasync-client/test/DataManagerTest.ts +++ b/client/datasync-client/test/DataManagerTest.ts @@ -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', {