diff --git a/Core/UpdateController.cpp b/Core/UpdateController.cpp index e52a8be..6faf1e8 100644 --- a/Core/UpdateController.cpp +++ b/Core/UpdateController.cpp @@ -36,53 +36,27 @@ QList UpdateController::calculateHash(QString path,QString ignoreName) { qDebug() << "Try calculate"; - QDir dir(path); - QDirIterator iterator(dir,QDirIterator::Subdirectories); + if(!QDir(path).exists()) + { + QDir().mkdir(path); + } + QList *hashes = new QList; - if(!QDir(path).exists()) - { //проверка на наличие папки - QDir().mkdir(path); - } - + QStringList filter; + filter << "*"; QString hashString; - while (iterator.hasNext()) + QDirIterator dirIterator(path,filter, QDir::AllEntries | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + + while (dirIterator.hasNext()) { - iterator.next(); - QFileInfo fileInfo = iterator.fileInfo(); + QFileInfo fileInfo(dirIterator.next()); FileData currentFile; - QFile file(fileInfo.absoluteFilePath()); - - quint64 fileSize = file.size(); //буффер для хэширования крупных файлов - const quint64 bufferSize = 10240; - - if(fileInfo.isHidden()) continue; - if(ignoreName != "" && fileInfo.path().contains(ignoreName)) continue; - - if(fileInfo.isFile() && file.open(QIODevice::ReadOnly)) + QString fileName = fileInfo.fileName(); + if(fileInfo.isDir() && !fileInfo.fileName().startsWith(".") && fileInfo.fileName() != "RRJLoader") { - char buffer[bufferSize]; - int bytesRead; - int readSize = qMin(fileSize,bufferSize); - - QCryptographicHash hash(QCryptographicHash::Md5); - - while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0){ - fileSize -= bytesRead; - hash.addData(buffer,bytesRead); - readSize = qMin(fileSize,bufferSize); - } - - hashString = QString(hash.result().toHex()); currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); - currentFile.hash = hashString; - hashes->push_back(currentFile); - file.close(); - } - else if (fileInfo.isDir() && !fileInfo.isRoot() && fileInfo.fileName() != "..") - { - currentFile.path = Tools::createLocalPath(fileInfo.path()); currentFile.hash = "FOLDER"; if(!hashes->contains(currentFile)) @@ -90,10 +64,106 @@ QList UpdateController::calculateHash(QString path,QString ignoreName) hashes->push_back(currentFile); } } - } - std::sort(hashes->begin(),hashes->end()); + QDirIterator fileIterator(path,filter,QDir::Files | QDir::NoDotAndDotDot,QDirIterator::Subdirectories); + + while (fileIterator.hasNext()) + { + fileIterator.next(); + QFileInfo fileInfo = fileIterator.fileInfo(); + FileData currentFile; + QFile file(fileInfo.absoluteFilePath()); + + quint64 fileSize = file.size(); //буффер для хэширования крупных файлов + const quint64 bufferSize = 10240; + + if(fileInfo.isHidden()) continue; + if(ignoreName != "" && fileInfo.path().contains(ignoreName)) continue; + + if(fileInfo.isFile() && file.open(QIODevice::ReadOnly)) + { + char buffer[bufferSize]; + int bytesRead; + int readSize = qMin(fileSize,bufferSize); + + QCryptographicHash hash(QCryptographicHash::Md5); + + while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0) + { + fileSize -= bytesRead; + hash.addData(buffer,bytesRead); + readSize = qMin(fileSize,bufferSize); + } + + hashString = QString(hash.result().toHex()); + currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); + currentFile.hash = hashString; + hashes->push_back(currentFile); + file.close(); + } + } + + +// QDirIterator iterator(dir,QDirIterator::Subdirectories); +// + +// if(!QDir(path).exists()) +// { //проверка на наличие папки +// QDir().mkdir(path); +// } + +// QString hashString; + +// while (iterator.hasNext()) +// { +// iterator.next(); +// QFileInfo fileInfo = iterator.fileInfo(); +// FileData currentFile; +// QFile file(fileInfo.absoluteFilePath()); + +// quint64 fileSize = file.size(); //буффер для хэширования крупных файлов +// const quint64 bufferSize = 10240; + +// if(fileInfo.isHidden()) continue; +// if(ignoreName != "" && fileInfo.path().contains(ignoreName)) continue; + +// if(fileInfo.isFile() && file.open(QIODevice::ReadOnly)) +// { +// char buffer[bufferSize]; +// int bytesRead; +// int readSize = qMin(fileSize,bufferSize); + +// QCryptographicHash hash(QCryptographicHash::Md5); + +// while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0){ +// fileSize -= bytesRead; +// hash.addData(buffer,bytesRead); +// readSize = qMin(fileSize,bufferSize); +// } + +// hashString = QString(hash.result().toHex()); +// currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); +// currentFile.hash = hashString; +// hashes->push_back(currentFile); +// file.close(); +// } +// else if (fileInfo.isDir() && !fileInfo.isRoot() && fileInfo.fileName() != "..") +// { +// currentFile.path = Tools::createLocalPath(fileInfo.path()); +// currentFile.hash = "FOLDER"; + +// if(!hashes->contains(currentFile)) +// { +// hashes->push_back(currentFile); +// } +// } + +// } + + + + //std::sort(hashes->begin(),hashes->end()); return *hashes; } diff --git a/Core/dataparser.cpp b/Core/dataparser.cpp index b1ad98a..d9f32a7 100644 --- a/Core/dataparser.cpp +++ b/Core/dataparser.cpp @@ -416,7 +416,17 @@ void DataParser::xmlParser(QByteArray array) if (value == "BASEDELETETRY") { - emit sigNotify("Нельзя удалять базовую версию"); + emit sigNotify(tr("Нельзя удалять базовую версию")); + } + + if (value == "TRYACTIVEDELETE") + { + emit sigNotify(tr("Нельзя удалять активную версию")); + } + + if (value == "DUPLICATEVERNAME") + { + emit sigNotify(tr("Такое имя уже существет")); } } } diff --git a/RRJClient.pro.user b/RRJClient.pro.user index 6d158cb..2228674 100644 --- a/RRJClient.pro.user +++ b/RRJClient.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/StaticData/authData.xml b/StaticData/authData.xml index 581514f..9429aff 100644 --- a/StaticData/authData.xml +++ b/StaticData/authData.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/StaticData/clientHash.xml b/StaticData/clientHash.xml index 9e6e087..845f215 100644 --- a/StaticData/clientHash.xml +++ b/StaticData/clientHash.xml @@ -1,4 +1,201 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StaticData/serverHash.xml b/StaticData/serverHash.xml index f8ea7ba..67fc33c 100644 --- a/StaticData/serverHash.xml +++ b/StaticData/serverHash.xml @@ -1,107 +1,47 @@ - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -112,7 +52,7 @@ - + @@ -122,47 +62,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -172,7 +72,7 @@ - + @@ -182,7 +82,105 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StaticData/settings.xml b/StaticData/settings.xml index 8877b7c..4b28bef 100644 --- a/StaticData/settings.xml +++ b/StaticData/settings.xml @@ -1,5 +1,5 @@ - + - + diff --git a/StaticData/streamingHash.xml b/StaticData/streamingHash.xml index 897a32a..fb2c4a3 100644 --- a/StaticData/streamingHash.xml +++ b/StaticData/streamingHash.xml @@ -1,2 +1,16 @@ - + + + + + + + + + + + + + + + diff --git a/Widgets/versionselectwidget.cpp b/Widgets/versionselectwidget.cpp index 4231c00..82a3fcf 100644 --- a/Widgets/versionselectwidget.cpp +++ b/Widgets/versionselectwidget.cpp @@ -67,15 +67,7 @@ void VersionSelectWidget::sendCopyEmit(QString newName) return; } - quint16 matchIndex = ui->verListView->findItems(newName,Qt::MatchFlag::MatchFixedString).length(); - - if (matchIndex > 0) - { - sigSendNotify(tr("Версия с таким именем уже существует")); - return; - } - - versionContainer->setLocalVersionData(selectedVersion); + //versionContainer->setLocalVersionData(selectedVersion); emit sigSendCopyVersion(result); } @@ -87,17 +79,6 @@ void VersionSelectWidget::on_DeleteVersionButton_clicked() return; } -// if (selectedVersion->getViewName() == baseNamePackage) -// { -// showWarning(tr("Нельзя удалить базовый пакет")); -// return; -// } - -// if (selectedVersion->getViewName() == versionContainer->getServerVersion()) -// { -// showWarning(tr("Нельзя удалить активную версию")); -// return; -// } emit sigSendDeleteVersion(selectedVersion); } diff --git a/debug/RRJClient.exe b/debug/RRJClient.exe index 2e31b9c..b412e8e 100644 Binary files a/debug/RRJClient.exe and b/debug/RRJClient.exe differ diff --git a/debug/dataparser.o b/debug/dataparser.o index 9d68ad6..f3d9961 100644 Binary files a/debug/dataparser.o and b/debug/dataparser.o differ diff --git a/debug/mainwindow.o b/debug/mainwindow.o index 724ab28..a097329 100644 Binary files a/debug/mainwindow.o and b/debug/mainwindow.o differ diff --git a/debug/updatecontroller.o b/debug/updatecontroller.o index 9b1e5e1..6f29817 100644 Binary files a/debug/updatecontroller.o and b/debug/updatecontroller.o differ diff --git a/debug/versionselectwidget.o b/debug/versionselectwidget.o index 32c0252..08d1a95 100644 Binary files a/debug/versionselectwidget.o and b/debug/versionselectwidget.o differ diff --git a/mainwindow.cpp b/mainwindow.cpp index a2e5ec0..6e54393 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -473,6 +473,14 @@ void MainWindow::on_unsafeChangingButton_clicked() void MainWindow::on_exitButton_clicked() { + workerThread->quit(); + workerThread->wait(); + + emit sigSendXMLAnswer(cmd_Disable); + + delete workerThread; + delete ui; + exit(0); }