2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-10-13 13:58:04 +00:00

Allow skipping stuck files in data export.

Fixes #6423.
This commit is contained in:
John Preston
2021-03-22 16:32:40 +04:00
parent 12db51fe75
commit 03a868a6e3
11 changed files with 150 additions and 22 deletions

View File

@@ -51,12 +51,14 @@ public:
void startExport(
const Settings &settings,
const Environment &environment);
void skipFile(uint64 randomId);
void cancelExportFast();
private:
using Step = ProcessingState::Step;
using DownloadProgress = ApiWrap::DownloadProgress;
[[nodiscard]] bool stopped() const;
void setState(State &&state);
void ioError(const QString &path);
bool ioCatchError(Output::Result result);
@@ -166,8 +168,15 @@ rpl::producer<State> ControllerObject::state() const {
});
}
bool ControllerObject::stopped() const {
return v::is<CancelledState>(_state)
|| v::is<ApiErrorState>(_state)
|| v::is<OutputErrorState>(_state)
|| v::is<FinishedState>(_state);
}
void ControllerObject::setState(State &&state) {
if (v::is<CancelledState>(_state)) {
if (stopped()) {
return;
}
_state = std::move(state);
@@ -245,6 +254,13 @@ void ControllerObject::startExport(
exportNext();
}
void ControllerObject::skipFile(uint64 randomId) {
if (stopped()) {
return;
}
_api.skipFile(randomId);
}
void ControllerObject::fillExportSteps() {
using Type = Settings::Type;
_steps.push_back(Step::Initializing);
@@ -518,6 +534,7 @@ ProcessingState ControllerObject::stateUserpics(
result.entityIndex = _userpicsWritten + progress.itemIndex;
result.entityCount = std::max(_userpicsCount, result.entityIndex);
result.bytesType = ProcessingState::FileType::Photo;
result.bytesRandomId = progress.randomId;
if (!progress.path.isEmpty()) {
const auto last = progress.path.lastIndexOf('/');
result.bytesName = progress.path.mid(last + 1);
@@ -570,6 +587,7 @@ void ControllerObject::fillMessagesState(
result.itemIndex = _messagesWritten + progress.itemIndex;
result.itemCount = std::max(_messagesCount, result.itemIndex);
result.bytesType = ProcessingState::FileType::File; // TODO
result.bytesRandomId = progress.randomId;
if (!progress.path.isEmpty()) {
const auto last = progress.path.lastIndexOf('/');
result.bytesName = progress.path.mid(last + 1);
@@ -643,6 +661,12 @@ void Controller::startExport(
});
}
void Controller::skipFile(uint64 randomId) {
_wrapped.with([=](Implementation &unwrapped) {
unwrapped.skipFile(randomId);
});
}
void Controller::cancelExportFast() {
LOG(("Export Info: Cancelled export."));