mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +02:00
use NotStarted instead of Unsent, return NotFound for Files
This commit is contained in:
parent
0ef459f7a9
commit
d908cd4a53
4 changed files with 16 additions and 9 deletions
|
@ -15,14 +15,21 @@
|
|||
|
||||
void FileResourceRequest::doSend() {
|
||||
QString filename = _url.toLocalFile();
|
||||
|
||||
QFile file(filename);
|
||||
|
||||
_state = Finished;
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
_data = file.readAll();
|
||||
_result = ResourceRequest::Success;
|
||||
emit finished();
|
||||
if (file.exists()) {
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
_data = file.readAll();
|
||||
_result = ResourceRequest::Success;
|
||||
emit finished();
|
||||
} else {
|
||||
_result = ResourceRequest::AccessDenied;
|
||||
emit finished();
|
||||
}
|
||||
} else {
|
||||
_result = ResourceRequest::AccessDenied;
|
||||
_result = ResourceRequest::NotFound;
|
||||
emit finished();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ void HTTPResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesT
|
|||
}
|
||||
|
||||
void HTTPResourceRequest::onTimeout() {
|
||||
Q_ASSERT(_state != Unsent);
|
||||
Q_ASSERT(_state != NotStarted);
|
||||
|
||||
if (_state == InProgress) {
|
||||
qCDebug(networking) << "Timed out loading " << _url;
|
||||
|
|
|
@ -17,7 +17,7 @@ ResourceRequest::ResourceRequest(QObject* parent, const QUrl& url) :
|
|||
}
|
||||
|
||||
void ResourceRequest::send() {
|
||||
Q_ASSERT(_state == Unsent);
|
||||
Q_ASSERT(_state == NotStarted);
|
||||
|
||||
_state = InProgress;
|
||||
doSend();
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
ResourceRequest(QObject* parent, const QUrl& url);
|
||||
|
||||
enum State {
|
||||
Unsent = 0,
|
||||
NotStarted = 0,
|
||||
InProgress,
|
||||
Finished
|
||||
};
|
||||
|
@ -51,7 +51,7 @@ protected:
|
|||
virtual void doSend() = 0;
|
||||
|
||||
QUrl _url;
|
||||
State _state { Unsent };
|
||||
State _state { NotStarted };
|
||||
Result _result;
|
||||
QByteArray _data;
|
||||
bool _cacheEnabled { true };
|
||||
|
|
Loading…
Reference in a new issue