Fix file reference updating.
This commit is contained in:
		
							parent
							
								
									aa8f62da9d
								
							
						
					
					
						commit
						3f49796c43
					
				
					 2 changed files with 28 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -762,7 +762,9 @@ void mtpFileLoader::makeRequest(int offset) {
 | 
			
		|||
					MTP_int(offset),
 | 
			
		||||
					MTP_int(limit)),
 | 
			
		||||
				rpcDone(&mtpFileLoader::normalPartLoaded),
 | 
			
		||||
				rpcFail(&mtpFileLoader::partFailed),
 | 
			
		||||
				rpcFail(
 | 
			
		||||
					&mtpFileLoader::normalPartFailed,
 | 
			
		||||
					computeFileReference()),
 | 
			
		||||
				shiftedDcId,
 | 
			
		||||
				50);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -785,6 +787,15 @@ MTPInputFileLocation mtpFileLoader::computeLocation() const {
 | 
			
		|||
		MTP_string(QString()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QByteArray mtpFileLoader::computeFileReference() const {
 | 
			
		||||
	if (_location) {
 | 
			
		||||
		return _location->fileReference();
 | 
			
		||||
	} else if (_locationType == SecureFileLocation) {
 | 
			
		||||
		return QByteArray();
 | 
			
		||||
	}
 | 
			
		||||
	return _fileReference;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void mtpFileLoader::requestMoreCdnFileHashes() {
 | 
			
		||||
	Expects(!_finished);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1076,7 +1087,8 @@ void mtpFileLoader::partLoaded(int offset, bytes::const_span buffer) {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool mtpFileLoader::partFailed(
 | 
			
		||||
bool mtpFileLoader::normalPartFailed(
 | 
			
		||||
		QByteArray fileReference,
 | 
			
		||||
		const RPCError &error,
 | 
			
		||||
		mtpRequestId requestId) {
 | 
			
		||||
	if (MTP::isDefaultHandledError(error)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1088,9 +1100,19 @@ bool mtpFileLoader::partFailed(
 | 
			
		|||
			_origin,
 | 
			
		||||
			this,
 | 
			
		||||
			requestId,
 | 
			
		||||
			_location ? _location->fileReference() : _fileReference);
 | 
			
		||||
			fileReference);
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	return partFailed(error, requestId);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool mtpFileLoader::partFailed(
 | 
			
		||||
		const RPCError &error,
 | 
			
		||||
		mtpRequestId requestId) {
 | 
			
		||||
	if (MTP::isDefaultHandledError(error)) {
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	cancel(true);
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -273,7 +273,8 @@ private:
 | 
			
		|||
	RequestData prepareRequest(int offset) const;
 | 
			
		||||
	void makeRequest(int offset);
 | 
			
		||||
 | 
			
		||||
	MTPInputFileLocation computeLocation() const;
 | 
			
		||||
	[[nodiscard]] MTPInputFileLocation computeLocation() const;
 | 
			
		||||
	[[nodiscard]] QByteArray computeFileReference() const;
 | 
			
		||||
	bool loadPart() override;
 | 
			
		||||
	void normalPartLoaded(const MTPupload_File &result, mtpRequestId requestId);
 | 
			
		||||
	void webPartLoaded(const MTPupload_WebFile &result, mtpRequestId requestId);
 | 
			
		||||
| 
						 | 
				
			
			@ -286,6 +287,7 @@ private:
 | 
			
		|||
	void partLoaded(int offset, bytes::const_span buffer);
 | 
			
		||||
 | 
			
		||||
	bool partFailed(const RPCError &error, mtpRequestId requestId);
 | 
			
		||||
	bool normalPartFailed(QByteArray fileReference, const RPCError &error, mtpRequestId requestId);
 | 
			
		||||
	bool cdnPartFailed(const RPCError &error, mtpRequestId requestId);
 | 
			
		||||
 | 
			
		||||
	void placeSentRequest(mtpRequestId requestId, const RequestData &requestData);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue