diff --git a/app/gui/oven_control/fileprocessdlg.cpp b/app/gui/oven_control/fileprocessdlg.cpp index 9a2cf8b..b6d99f6 100644 --- a/app/gui/oven_control/fileprocessdlg.cpp +++ b/app/gui/oven_control/fileprocessdlg.cpp @@ -37,6 +37,7 @@ void ProgramCopyWorker::workerMain(){ QStringList strdirlist; QString srcFilepath; QString destFilePath; + bool m_bRst=true; //make destination folder QDir destdir(m_strDestDir); @@ -58,8 +59,10 @@ void ProgramCopyWorker::workerMain(){ } qDebug() << " Dir List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize; if(nTotalFileSize <=0 ){ + emit errorFired("SIZE ERROR "); + QThread::currentThread()->msleep(5000); emit finished(); - progressed(0,0); + emit progressed(0,0); return; } @@ -75,7 +78,13 @@ void ProgramCopyWorker::workerMain(){ if(QFile::exists(destFilePath)){ QFile::rename(destFilePath, QString("%1.bak").arg(destFilePath)); } - QFile::copy(srcFilepath,destFilePath); + if(QFile::copy(srcFilepath,destFilePath)==false){ + qDebug() << srcFilepath << " file copy fail!"; + m_bRst = false; + emit errorFired(finfo.fileName()); + QThread::currentThread()->msleep(5000); + break; + } nCpyFileSize += finfo.size(); nCurProgress = (nCpyFileSize *100) / nTotalFileSize; nRemainSec = (nTotalFileSize-nCpyFileSize)/200000; @@ -87,13 +96,22 @@ void ProgramCopyWorker::workerMain(){ } QThread::currentThread()->msleep(10); } + qDebug() << "File List Copy Finished"; - if(QThread::currentThread()->isInterruptionRequested() == false){ + if(QThread::currentThread()->isInterruptionRequested() == false || m_bRst == false){ foreach(QString srcpath, m_arrSrcDirList){ qDebug() << "src dir : " << srcpath; QDir srcdir(srcpath); + if(srcdir.exists() == false){ + qDebug() << "Source Dir is not exist"; + m_bRst = false; + emit errorFired("DIR not exist"); + QThread::currentThread()->msleep(5000); + break; + } + strdirlist.append(srcpath); FileProcessor::getAllDirList(srcdir, strdirlist); qDebug() << "dir size : " <msleep(5000); + break; } nCpyFileSize += finfo.size(); nCurProgress = (nCpyFileSize *100) / nTotalFileSize; @@ -129,7 +151,7 @@ void ProgramCopyWorker::workerMain(){ } //QThread::currentThread()->msleep(100); } - if(QThread::currentThread()->isInterruptionRequested()) break; + if(QThread::currentThread()->isInterruptionRequested() || m_bRst == false) break; } strdirlist.clear(); if(QThread::currentThread()->isInterruptionRequested()) break; @@ -137,7 +159,7 @@ void ProgramCopyWorker::workerMain(){ } qDebug() << "File Copy Complete! SRC File Size = " << nTotalFileSize << "DEST File Size = " << nCpyFileSize; - if(QThread::currentThread()->isInterruptionRequested()){ + if(QThread::currentThread()->isInterruptionRequested() || m_bRst == false){ foreach(QString strinfo, m_arrSrcFileList){ QString filepath = strinfo.left(strinfo.indexOf(',',0)+1); QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1)); @@ -540,11 +562,13 @@ void FileProcessDlg::programDownload(){ if(FileProcessor::detectUSB(strDescPath)){ worker.setDestPath(QString("%1/prime").arg(strDescPath)); - worker.addSrcDir("/prime/cookbook"); + worker.addSrcDir("/prime/history"); + worker.addSrcDir("/prime/program"); worker.moveToThread(&programCopyThd); connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain())); connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int))); + connect(&worker, SIGNAL(errorFired(QString)), this, SLOT(onErrorFired(QString))); connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop())); connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit())); connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished())); @@ -564,6 +588,12 @@ void FileProcessDlg::onProgressFinished(){ QTimer::singleShot(1000,this, SLOT(close())); } +void FileProcessDlg::onErrorFired(QString Desc) +{ + ui->ctrLbRemainTime->setText(QString("%1 %2").arg(Desc).arg(tr("에러 발생으로 종료합니다."))); + //QTimer::singleShot(1000,this, SLOT(close())); +} + void FileProcessDlg::onProgressed(int progress, int sec){ int min, _sec; QString strTemp; @@ -595,13 +625,14 @@ void FileProcessDlg::programUpload(){ worker.addSrcFile(QString("%1/prime/superdaemon.ini.md5,/prime").arg(strSrcPath)); worker.addSrcFile(QString("%1/prime/superdaemon.md5,/prime").arg(strSrcPath)); worker.setDestPath("/prime"); - worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/cookbook")); + //worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/cookbook")); //쿡북 복사 삭제 worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/templates")); worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/sounds")); worker.moveToThread(&programCopyThd); connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain())); connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int))); + connect(&worker,SIGNAL(errorFired(QString)),this,SLOT(onErrorFired(QString))); connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop())); connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit())); connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished())); diff --git a/app/gui/oven_control/fileprocessdlg.h b/app/gui/oven_control/fileprocessdlg.h index b9e8d36..e7a4841 100644 --- a/app/gui/oven_control/fileprocessdlg.h +++ b/app/gui/oven_control/fileprocessdlg.h @@ -41,6 +41,7 @@ public slots: signals: void finished(); void progressed(int progress, int sec); + void errorFired(QString Desc); }; class FileProcessDlg : public QDialog @@ -70,6 +71,7 @@ signals: public slots: void onProgressed(int progress,int sec); void onProgressFinished(); + void onErrorFired(QString Desc); protected: void keyPressEvent(QKeyEvent* event);