mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 22:46:10 +00:00
Differ file download failure reasons
..and uncomment the code for handling incorrect permissions
This commit is contained in:
@@ -128,12 +128,12 @@ void FileLoader::finishWithBytes(const QByteArray &data) {
|
||||
if (!_filename.isEmpty() && _toCache == LoadToCacheAsWell) {
|
||||
if (!_fileIsOpen) _fileIsOpen = _file.open(QIODevice::WriteOnly);
|
||||
if (!_fileIsOpen) {
|
||||
cancel(true);
|
||||
cancel(FailureReason::FileWriteFailure);
|
||||
return;
|
||||
}
|
||||
_file.seek(0);
|
||||
if (_file.write(_data) != qint64(_data.size())) {
|
||||
cancel(true);
|
||||
cancel(FailureReason::FileWriteFailure);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -258,7 +258,7 @@ bool FileLoader::checkForOpen() {
|
||||
if (_fileIsOpen) {
|
||||
return true;
|
||||
}
|
||||
cancel(true);
|
||||
cancel(FailureReason::FileWriteFailure);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -329,10 +329,10 @@ bool FileLoader::tryLoadLocal() {
|
||||
}
|
||||
|
||||
void FileLoader::cancel() {
|
||||
cancel(false);
|
||||
cancel(FailureReason::NoFailure);
|
||||
}
|
||||
|
||||
void FileLoader::cancel(bool fail) {
|
||||
void FileLoader::cancel(FailureReason fail) {
|
||||
const auto started = (currentOffset() > 0);
|
||||
|
||||
cancelHook();
|
||||
@@ -347,8 +347,8 @@ void FileLoader::cancel(bool fail) {
|
||||
_data = QByteArray();
|
||||
|
||||
const auto weak = base::make_weak(this);
|
||||
if (fail) {
|
||||
_updates.fire_error_copy(started);
|
||||
if (fail != FailureReason::NoFailure) {
|
||||
_updates.fire_error_copy({ fail, started });
|
||||
} else {
|
||||
_updates.fire_done();
|
||||
}
|
||||
@@ -377,7 +377,7 @@ bool FileLoader::writeResultPart(int64 offset, bytes::const_span buffer) {
|
||||
}
|
||||
_file.seek(offset);
|
||||
if (_file.write(reinterpret_cast<const char*>(buffer.data()), buffer.size()) != qint64(buffer.size())) {
|
||||
cancel(true);
|
||||
cancel(FailureReason::FileWriteFailure);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -410,7 +410,7 @@ QByteArray FileLoader::readLoadedPartBack(int64 offset, int size) {
|
||||
_file.close();
|
||||
_fileIsOpen = _file.open(QIODevice::ReadWrite);
|
||||
if (!_fileIsOpen) {
|
||||
cancel(true);
|
||||
cancel(FailureReason::FileWriteFailure);
|
||||
return QByteArray();
|
||||
}
|
||||
}
|
||||
@@ -434,7 +434,7 @@ bool FileLoader::finalizeResult() {
|
||||
}
|
||||
_file.seek(0);
|
||||
if (!_fileIsOpen || _file.write(_data) != qint64(_data.size())) {
|
||||
cancel(true);
|
||||
cancel(FailureReason::FileWriteFailure);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user