Skip to content

Commit 701ae56

Browse files
authored
fix: transfer removed activity callback and connect not working with allow_dialogs (#197)
1 parent dd7fab4 commit 701ae56

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/app/core.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,20 @@ export const startTransfer = (transferSpec: TransferSpec, asperaSdkSpec?: Aspera
211211
if (asperaSdk.useHttpGateway) {
212212
return transferSpec.direction === 'receive' ? httpDownload(transferSpec, asperaSdkSpec) : httpUpload(transferSpec, asperaSdkSpec);
213213
} else if (asperaSdk.useConnect) {
214+
/**
215+
* There is a bug in the Connect transfer client where Connect's HTTP server will no longer return ANY responses if a dialog was opened
216+
* when starting the transfer (ex: request or file overwrite confirmation).
217+
*/
218+
if (asperaSdkSpec?.allow_dialogs !== false) {
219+
console.warn(
220+
'[Aspera SDK] `allow_dialogs` was not set to `false` in AsperaSdkSpec and has been overridden. ' +
221+
'Connect dialogs block all subsequent HTTP responses. ' +
222+
'Set `allow_dialogs: false` explicitly to suppress this warning. ' +
223+
'More info: https://github.com/IBM/aspera-sdk-js/issues/196'
224+
);
225+
asperaSdkSpec = { ...asperaSdkSpec, allow_dialogs: false };
226+
}
227+
214228
return asperaSdk.globals.connect.startTransferPromise(transferSpec as unknown as ConnectTypes.TransferSpec, asperaSdkSpec).then(response => {
215229
return response.transfer_specs[0] as unknown as AsperaSdkTransfer;
216230
});

src/models/aspera-sdk.model.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,19 @@ export class ActivityTracking {
135135
private lastNotifiedWebSocketEvent: WebsocketEvent = undefined;
136136

137137
/**
138-
* Notify all consumers when a message is received from the websocket
138+
* Notify all consumers when a message is received from the transfer client.
139139
*
140-
* @param message the message received from the websocket
140+
* @param message the message received
141141
*/
142142
handleTransferActivity(message: ActivityMessage): void {
143+
const data = message.data && typeof message.data === 'object' && 'transfers' in message.data
144+
? message.data
145+
: {transfers: [message.data]};
146+
143147
if (message.type === 'transferUpdated' || message.type === 'transferRemoved') {
144148
this.activity_callbacks.forEach(callback => {
145149
if (typeof callback === 'function') {
146-
callback(message.data);
150+
callback(data);
147151
}
148152
});
149153
}

0 commit comments

Comments
 (0)