Skip to content

Commit 6658f67

Browse files
author
doubleface
committed
feat: Allow to clean the pouches with dataproxy.cleanPouches flag
1 parent 05fa301 commit 6658f67

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/dataproxy/worker/worker.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,24 @@ const dataProxy: DataProxyWorker = {
188188
return queryRes
189189
},
190190

191-
forceSyncPouch: () => {
191+
forceSyncPouch: async (
192+
options: { clean: boolean } = { clean: false }
193+
): Promise<void> => {
192194
if (!client) {
193195
throw new Error(
194196
'Client is required to execute a forceSyncPouch, please initialize CozyClient'
195197
)
196198
}
197199
const pouchLink = getPouchLink(client)
198200
if (pouchLink) {
201+
if (options.clean) {
202+
await pouchLink.reset()
203+
await pouchLink.registerClient(client) // because reset also resets the client
204+
await pouchLink.onLogin()
205+
} else {
206+
await pouchLink.pouches.waitForCurrentReplications()
207+
}
208+
199209
pouchLink.startReplication()
200210
}
201211
},

0 commit comments

Comments
 (0)