Skip to content

Commit

Permalink
Handle LOCATION_INVALID error.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 24, 2018
1 parent 1ae3af0 commit f7aadc3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
25 changes: 23 additions & 2 deletions Telegram/SourceFiles/export/export_api_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ auto ApiWrap::fileRequest(const Data::FileLocation &location, int offset) {
filePartDone(0, MTP_upload_file(MTP_storage_filePartial(),
MTP_int(0),
MTP_bytes(QByteArray())));
} else if (result.type() == qstr("LOCATION_INVALID")) {
filePartUnavailable();
} else {
error(std::move(result));
}
Expand Down Expand Up @@ -558,8 +560,11 @@ void ApiWrap::requestOtherData(
void ApiWrap::otherDataDone(const QString &relativePath) {
Expects(_otherDataProcess != nullptr);

_otherDataProcess->file.relativePath = relativePath;
const auto process = base::take(_otherDataProcess);
process->file.relativePath = relativePath;
if (relativePath.isEmpty()) {
process->file.skipReason = Data::File::SkipReason::Unavailable;
}
process->done(std::move(process->file));
}

Expand Down Expand Up @@ -696,6 +701,9 @@ void ApiWrap::loadUserpicDone(const QString &relativePath) {
const auto index = _userpicsProcess->fileIndex;
auto &file = _userpicsProcess->slice->list[index].image.file;
file.relativePath = relativePath;
if (relativePath.isEmpty()) {
file.skipReason = Data::File::SkipReason::Unavailable;
}
loadNextUserpic();
}

Expand Down Expand Up @@ -1139,7 +1147,11 @@ void ApiWrap::loadMessageFileDone(const QString &relativePath) {
&& (_chatProcess->fileIndex < _chatProcess->slice->list.size()));

const auto index = _chatProcess->fileIndex;
_chatProcess->slice->list[index].file().relativePath = relativePath;
auto &file = _chatProcess->slice->list[index].file();
file.relativePath = relativePath;
if (relativePath.isEmpty()) {
file.skipReason = Data::File::SkipReason::Unavailable;
}
loadNextMessageFile();
}

Expand Down Expand Up @@ -1352,6 +1364,15 @@ void ApiWrap::filePartDone(int offset, const MTPupload_File &result) {
process->done(process->relativePath);
}

void ApiWrap::filePartUnavailable() {
Expects(_fileProcess != nullptr);
Expects(!_fileProcess->requests.empty());

LOG(("Export Error: File unavailable."));

base::take(_fileProcess)->done(QString());
}

void ApiWrap::error(RPCError &&error) {
_errors.fire(std::move(error));
}
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/export/export_api_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class ApiWrap {
FnMut<void(QString)> done);
void loadFilePart();
void filePartDone(int offset, const MTPupload_File &result);
void filePartUnavailable();

template <typename Request>
[[nodiscard]] auto mainRequest(Request &&request);
Expand Down

0 comments on commit f7aadc3

Please sign in to comment.