mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-10-13 13:58:04 +00:00
@@ -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."));
|
||||
|
||||
|
Reference in New Issue
Block a user