bugfix: loading process disable

This commit is contained in:
semenov
2025-01-16 11:12:46 +03:00
parent adbd8395ca
commit e7b13f4ec4
10 changed files with 54 additions and 84 deletions

View File

@@ -35,14 +35,22 @@ void SendSystem::sendMessageBlock(QString message)
void SendSystem::sendFileBlock(QString path)
{
qDebug() << "sendFileBlock thread: " << QThread::currentThreadId();
QFile file(path);
QFileInfo fileInfo(file);
if(isSendStopped)
{ //Поведение на случай отключения клиента
file.close();
return;
}
QDataStream stream(socket);
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
QFile file(path);
QFileInfo fileInfo(file);
fileSize = fileInfo.size();
if(fileSize == 0){
@@ -55,20 +63,19 @@ void SendSystem::sendFileBlock(QString path)
stream << path << fileSize;
if(isSendStopped) { //Поведение на случай отключения клиента
file.close();
return;
}
socket->waitForBytesWritten();
socket->waitForBytesWritten(10);
if(file.open(QFile::ReadOnly)){
while(!file.atEnd()){
if(file.open(QFile::ReadOnly))
{
while(!file.atEnd())
{
QByteArray data = file.read(1025*250);
stream << data;
socket->waitForBytesWritten();
socket->waitForBytesWritten(10);
if(socket->state() == QAbstractSocket::UnconnectedState) break;
countSend++;
}
@@ -77,7 +84,7 @@ void SendSystem::sendFileBlock(QString path)
file.close();
countSend = 0;
socket->waitForBytesWritten();
socket->waitForBytesWritten(10);
socket->waitForReadyRead(100);
}
@@ -237,11 +244,9 @@ void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> delet
socket->waitForReadyRead(100);
}
if(getIsSendStopped()) return;
if(isSendStopped) return;
}
emit sigLoadHash();
sendPacketType(PacketType::TYPE_FINISH);