This commit is contained in:
Kovid Goyal 2023-01-28 13:33:53 +05:30
parent dd13c03bfc
commit 46731246c6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -682,12 +682,13 @@ save_stream(SpeechSynthesisStream const &&stream, std::filesystem::path path, id
outfile.open(path.string(), std::ios::out | std::ios::trunc);
ok = true;
} CATCH_ALL_EXCEPTIONS("Failed to create file: " + path.string(), cmd_id);
while (ok && bytes_read < stream_size) {
if (!ok) co_return;
while (bytes_read < stream_size) {
try {
n = co_await reader.LoadAsync(chunk_size);
ok = true;
} CATCH_ALL_EXCEPTIONS("Failed to load data from DataReader", cmd_id);
if (!ok) break;
if (!ok) co_return;
if (n > 0) {
bytes_read += n;
ok = false;
@ -697,7 +698,7 @@ save_stream(SpeechSynthesisStream const &&stream, std::filesystem::path path, id
if (!outfile.good()) throw "Failed to write to output file";
ok = true;
} CATCH_ALL_EXCEPTIONS("Failed to save bytes from DataReader to file", cmd_id);
if (!ok) break;
if (!ok) co_return;
}
}
output(cmd_id, "saved", {{"size", bytes_read}});