replay: fix qcam download error (#22777)

* fix qcam download error

* test loading qlog/qcamera
old-commit-hash: 79651b6c4917415c11d1b462a87e1e18853d6e68
This commit is contained in:
Dean Lee
2021-11-02 18:24:59 +08:00
committed by GitHub
parent 526cfdd0fb
commit 5f454307fc
3 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ std::string FileReader::download(const std::string &url, std::atomic<bool> *abor
std::ostringstream oss;
result.resize(remote_file_size);
oss.rdbuf()->pubsetbuf(result.data(), result.size());
int chunks = chunk_size_ > 0 ? std::min(1, (int)std::nearbyint(remote_file_size / (float)chunk_size_)) : 1;
int chunks = chunk_size_ > 0 ? std::max(1, (int)std::nearbyint(remote_file_size / (float)chunk_size_)) : 1;
if (httpMultiPartDownload(url, oss, chunks, remote_file_size, abort)) {
return result;
}
+1 -1
View File
@@ -28,7 +28,7 @@ public:
inline const QString &name() const { return route_.str; }
inline const RouteIdentifier &identifier() const { return route_; }
inline const std::map<int, SegmentFile> &segments() const { return segments_; }
inline const SegmentFile &at(int n) { return segments_.at(n); }
inline SegmentFile &at(int n) { return segments_.at(n); }
static RouteIdentifier parseRoute(const QString &str);
protected:
+5
View File
@@ -57,9 +57,14 @@ TEST_CASE("FileReader") {
}
TEST_CASE("Segment") {
auto test_qlog = GENERATE(false, true);
Route demo_route(DEMO_ROUTE);
REQUIRE(demo_route.load());
REQUIRE(demo_route.segments().size() == 11);
if (test_qlog) {
demo_route.at(0).road_cam = "";
demo_route.at(0).rlog = "";
}
QEventLoop loop;
Segment segment(0, demo_route.at(0), false, false, false);