Skip to content

Commit 79aa5aa

Browse files
jmartinesppoljar
authored andcommitted
refactor: Remove the default timeout when downloading media, rely on read_timeout instead
Users with poor network connectivity complained their downloads were cancelled for no good reason after 30s before (the default `timeout` value).
1 parent 0833ffd commit 79aa5aa

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

crates/matrix-sdk/src/media.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,18 +434,24 @@ impl Media {
434434
}
435435
}
436436

437+
let request_config = self
438+
.client
439+
.request_config()
440+
// Downloading a file should have no timeout as we don't know the network connectivity
441+
// available for the user or the file size
442+
.timeout(None);
443+
437444
// Use the authenticated endpoints when the server supports Matrix 1.11 or the
438445
// authenticated media stable feature.
439446
let (use_auth, request_config) =
440447
if self.client.server_versions().await?.contains(&MatrixVersion::V1_11) {
441-
(true, None)
448+
(true, request_config)
442449
} else if self.client.unstable_features().await?.contains(&FeatureFlag::Msc3916Stable) {
443450
// We need to force the use of the stable endpoint with the Matrix version
444451
// because Ruma does not handle stable features.
445-
let request_config = self.client.request_config();
446-
(true, Some(request_config.force_matrix_version(MatrixVersion::V1_11)))
452+
(true, request_config.force_matrix_version(MatrixVersion::V1_11))
447453
} else {
448-
(false, None)
454+
(false, request_config)
449455
};
450456

451457
let content: Vec<u8> = match &request.source {

0 commit comments

Comments
 (0)