mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
Merge pull request #15912 from strapi/data-transfer/end-transfer
This commit is contained in:
commit
acbb752d95
@ -35,10 +35,13 @@ class RemoteStrapiDestinationProvider implements IDestinationProvider {
|
|||||||
|
|
||||||
dispatcher: ReturnType<typeof createDispatcher> | null;
|
dispatcher: ReturnType<typeof createDispatcher> | null;
|
||||||
|
|
||||||
|
transferID: string | null;
|
||||||
|
|
||||||
constructor(options: IRemoteStrapiDestinationProviderOptions) {
|
constructor(options: IRemoteStrapiDestinationProviderOptions) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.ws = null;
|
this.ws = null;
|
||||||
this.dispatcher = null;
|
this.dispatcher = null;
|
||||||
|
this.transferID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async initTransfer(): Promise<string> {
|
async initTransfer(): Promise<string> {
|
||||||
@ -224,15 +227,23 @@ class RemoteStrapiDestinationProvider implements IDestinationProvider {
|
|||||||
this.ws = ws;
|
this.ws = ws;
|
||||||
this.dispatcher = createDispatcher(this.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');
|
await this.dispatcher.dispatchTransferAction('bootstrap');
|
||||||
}
|
}
|
||||||
|
|
||||||
async close() {
|
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) => {
|
await new Promise<void>((resolve) => {
|
||||||
const { ws } = this;
|
const { ws } = this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user