Fixed the bug that cause the file transfer to timeout if the user hasn't been quick enough to save his file
parent
5175b362f7
commit
03f7c674fa
|
@ -549,9 +549,11 @@ export class FileManager {
|
||||||
const initializeCallback = async () => {
|
const initializeCallback = async () => {
|
||||||
try {
|
try {
|
||||||
transfer.target = await transfer.targetSupplier(transfer);
|
transfer.target = await transfer.targetSupplier(transfer);
|
||||||
if(!transfer.target)
|
if(!transfer.target) {
|
||||||
throw tr("Failed to create transfer target");
|
throw tr("Failed to create transfer target");
|
||||||
|
}
|
||||||
|
|
||||||
|
transfer.lastStateUpdate = Date.now();
|
||||||
await this.connectionHandler.serverConnection.send_command("ftinitdownload", {
|
await this.connectionHandler.serverConnection.send_command("ftinitdownload", {
|
||||||
"path": options.path,
|
"path": options.path,
|
||||||
"name": options.name,
|
"name": options.name,
|
||||||
|
@ -565,7 +567,6 @@ export class FileManager {
|
||||||
if(transfer.transferState() === FileTransferState.INITIALIZING) {
|
if(transfer.transferState() === FileTransferState.INITIALIZING) {
|
||||||
throw tr("missing transfer start notify");
|
throw tr("missing transfer start notify");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
transfer.setFailed({
|
transfer.setFailed({
|
||||||
error: "initialize",
|
error: "initialize",
|
||||||
|
@ -588,9 +589,11 @@ export class FileManager {
|
||||||
const initializeCallback = async () => {
|
const initializeCallback = async () => {
|
||||||
try {
|
try {
|
||||||
transfer.source = await transfer.sourceSupplier(transfer);
|
transfer.source = await transfer.sourceSupplier(transfer);
|
||||||
if(!transfer.source)
|
if(!transfer.source) {
|
||||||
throw tr("Failed to create transfer source");
|
throw tr("Failed to create transfer source");
|
||||||
|
}
|
||||||
|
|
||||||
|
transfer.lastStateUpdate = Date.now();
|
||||||
transfer.fileSize = await transfer.source.fileSize();
|
transfer.fileSize = await transfer.source.fileSize();
|
||||||
await this.connectionHandler.serverConnection.send_command("ftinitupload", {
|
await this.connectionHandler.serverConnection.send_command("ftinitupload", {
|
||||||
"path": options.path,
|
"path": options.path,
|
||||||
|
@ -604,14 +607,15 @@ export class FileManager {
|
||||||
"proto": 1
|
"proto": 1
|
||||||
}, { process_result: options.processCommandResult });
|
}, { process_result: options.processCommandResult });
|
||||||
|
|
||||||
if(transfer.transferState() === FileTransferState.INITIALIZING)
|
if(transfer.transferState() === FileTransferState.INITIALIZING) {
|
||||||
throw tr("missing transfer start notify");
|
throw tr("missing transfer start notify");
|
||||||
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
transfer.setFailed({
|
transfer.setFailed({
|
||||||
error: "initialize",
|
error: "initialize",
|
||||||
commandResult: error
|
commandResult: error
|
||||||
}, error instanceof CommandResult ? error.formattedMessage() : typeof error === "string" ? error : tr("Lookup the console"));
|
}, error instanceof CommandResult ? error.formattedMessage() : typeof error === "string" ? error : tr("lookup the console"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -735,8 +739,18 @@ export class FileManager {
|
||||||
/* Transfer is locally pending because of some limits */
|
/* Transfer is locally pending because of some limits */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case FileTransferState.CONNECTING:
|
|
||||||
case FileTransferState.INITIALIZING:
|
case FileTransferState.INITIALIZING:
|
||||||
|
if(entry instanceof FileDownloadTransfer) {
|
||||||
|
if(!entry.target) {
|
||||||
|
/* We're still prompting the user for a target file location. Lets apply a timeout of 1 min. */
|
||||||
|
if(entry.transfer.lastStateUpdate < Date.now() + 60 * 1000) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case FileTransferState.CONNECTING:
|
||||||
case FileTransferState.RUNNING:
|
case FileTransferState.RUNNING:
|
||||||
/* These states can time out */
|
/* These states can time out */
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -686,12 +686,13 @@ export function initializeRemoteFileBrowserController(connection: ConnectionHand
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
events.on("action_start_download", event => {
|
events.on("action_start_download", async event => {
|
||||||
event.files.forEach(file => {
|
for(const file of event.files) {
|
||||||
try {
|
try {
|
||||||
let targetSupplier;
|
let targetSupplier;
|
||||||
if (__build.target === "client" && TransferProvider.provider().targetSupported(TransferTargetType.FILE)) {
|
if (__build.target === "client" && TransferProvider.provider().targetSupported(TransferTargetType.FILE)) {
|
||||||
const target = TransferProvider.provider().createFileTarget(undefined, file.name);
|
/* Get the target file path before we're actiually starting to download the file */
|
||||||
|
const target = await TransferProvider.provider().createFileTarget(undefined, file.name);
|
||||||
targetSupplier = async () => target;
|
targetSupplier = async () => target;
|
||||||
} else if (TransferProvider.provider().targetSupported(TransferTargetType.DOWNLOAD)) {
|
} else if (TransferProvider.provider().targetSupported(TransferTargetType.DOWNLOAD)) {
|
||||||
targetSupplier = async () => await TransferProvider.provider().createDownloadTarget();
|
targetSupplier = async () => await TransferProvider.provider().createDownloadTarget();
|
||||||
|
@ -717,7 +718,7 @@ export function initializeRemoteFileBrowserController(connection: ConnectionHand
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logError(LogCategory.FILE_TRANSFER, tr("Failed to parse path for file download: %s"), error);
|
logError(LogCategory.FILE_TRANSFER, tr("Failed to parse path for file download: %s"), error);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
events.on("action_start_upload", event => {
|
events.on("action_start_upload", event => {
|
||||||
|
|
Loading…
Reference in New Issue