Merge pull request #15912 from strapi/data-transfer/end-transfer

This commit is contained in:
Jean-Sébastien Herbaux 2023-02-24 15:27:43 +01:00 committed by GitHub
commit acbb752d95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,10 +35,13 @@ class RemoteStrapiDestinationProvider implements IDestinationProvider {
dispatcher: ReturnType<typeof createDispatcher> | null;
transferID: string | null;
constructor(options: IRemoteStrapiDestinationProviderOptions) {
this.options = options;
this.ws = null;
this.dispatcher = null;
this.transferID = null;
}
async initTransfer(): Promise<string> {
@ -224,15 +227,23 @@ class RemoteStrapiDestinationProvider implements IDestinationProvider {
this.ws = ws;
this.dispatcher = createDispatcher(this.ws);
const transferID = await this.initTransfer();
this.transferID = await this.initTransfer();
this.dispatcher.setTransferProperties({ id: transferID, kind: 'push' });
this.dispatcher.setTransferProperties({ id: this.transferID, kind: 'push' });
await this.dispatcher.dispatchTransferAction('bootstrap');
}
async close() {
await this.dispatcher?.dispatchTransferAction('close');
// Gracefully close the remote transfer process
if (this.transferID && this.dispatcher) {
await this.dispatcher.dispatchTransferAction('close');
await this.dispatcher.dispatchCommand({
command: 'end',
params: { transferID: this.transferID },
});
}
await new Promise<void>((resolve) => {
const { ws } = this;