Commit 7835a65554994a74bb9c3a12dd0d6f11c4a6b4a9

Authored by 고영탁
1 parent 1342af7b38
Exists in master and in 2 other branches fhd, fhd-demo

파일 복사 기능 수정

 - 복사 실패 시 복원
app/gui/oven_control/fileprocessdlg.cpp
@@ -37,6 +37,7 @@ void ProgramCopyWorker::workerMain(){ @@ -37,6 +37,7 @@ void ProgramCopyWorker::workerMain(){
37 QStringList strdirlist; 37 QStringList strdirlist;
38 QString srcFilepath; 38 QString srcFilepath;
39 QString destFilePath; 39 QString destFilePath;
  40 + bool m_bRst=true;
40 41
41 //make destination folder 42 //make destination folder
42 QDir destdir(m_strDestDir); 43 QDir destdir(m_strDestDir);
@@ -58,8 +59,10 @@ void ProgramCopyWorker::workerMain(){ @@ -58,8 +59,10 @@ void ProgramCopyWorker::workerMain(){
58 } 59 }
59 qDebug() << " Dir List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize; 60 qDebug() << " Dir List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize;
60 if(nTotalFileSize <=0 ){ 61 if(nTotalFileSize <=0 ){
  62 + emit errorFired("SIZE ERROR ");
  63 + QThread::currentThread()->msleep(5000);
61 emit finished(); 64 emit finished();
62 - progressed(0,0); 65 + emit progressed(0,0);
63 return; 66 return;
64 } 67 }
65 68
@@ -75,7 +78,13 @@ void ProgramCopyWorker::workerMain(){ @@ -75,7 +78,13 @@ void ProgramCopyWorker::workerMain(){
75 if(QFile::exists(destFilePath)){ 78 if(QFile::exists(destFilePath)){
76 QFile::rename(destFilePath, QString("%1.bak").arg(destFilePath)); 79 QFile::rename(destFilePath, QString("%1.bak").arg(destFilePath));
77 } 80 }
78 - QFile::copy(srcFilepath,destFilePath); 81 + if(QFile::copy(srcFilepath,destFilePath)==false){
  82 + qDebug() << srcFilepath << " file copy fail!";
  83 + m_bRst = false;
  84 + emit errorFired(finfo.fileName());
  85 + QThread::currentThread()->msleep(5000);
  86 + break;
  87 + }
79 nCpyFileSize += finfo.size(); 88 nCpyFileSize += finfo.size();
80 nCurProgress = (nCpyFileSize *100) / nTotalFileSize; 89 nCurProgress = (nCpyFileSize *100) / nTotalFileSize;
81 nRemainSec = (nTotalFileSize-nCpyFileSize)/200000; 90 nRemainSec = (nTotalFileSize-nCpyFileSize)/200000;
@@ -87,13 +96,22 @@ void ProgramCopyWorker::workerMain(){ @@ -87,13 +96,22 @@ void ProgramCopyWorker::workerMain(){
87 } 96 }
88 QThread::currentThread()->msleep(10); 97 QThread::currentThread()->msleep(10);
89 } 98 }
  99 +
90 qDebug() << "File List Copy Finished"; 100 qDebug() << "File List Copy Finished";
91 101
92 - if(QThread::currentThread()->isInterruptionRequested() == false){ 102 + if(QThread::currentThread()->isInterruptionRequested() == false || m_bRst == false){
93 foreach(QString srcpath, m_arrSrcDirList){ 103 foreach(QString srcpath, m_arrSrcDirList){
94 qDebug() << "src dir : " << srcpath; 104 qDebug() << "src dir : " << srcpath;
95 105
96 QDir srcdir(srcpath); 106 QDir srcdir(srcpath);
  107 + if(srcdir.exists() == false){
  108 + qDebug() << "Source Dir is not exist";
  109 + m_bRst = false;
  110 + emit errorFired("DIR not exist");
  111 + QThread::currentThread()->msleep(5000);
  112 + break;
  113 + }
  114 +
97 strdirlist.append(srcpath); 115 strdirlist.append(srcpath);
98 FileProcessor::getAllDirList(srcdir, strdirlist); 116 FileProcessor::getAllDirList(srcdir, strdirlist);
99 qDebug() << "dir size : " <<strdirlist.size(); 117 qDebug() << "dir size : " <<strdirlist.size();
@@ -115,7 +133,11 @@ void ProgramCopyWorker::workerMain(){ @@ -115,7 +133,11 @@ void ProgramCopyWorker::workerMain(){
115 srcFilepath = finfo.absoluteFilePath(); 133 srcFilepath = finfo.absoluteFilePath();
116 destFilePath = QString("%1/%2").arg(QString(strDir).replace(srcpath,targetpath)).arg(finfo.fileName()); 134 destFilePath = QString("%1/%2").arg(QString(strDir).replace(srcpath,targetpath)).arg(finfo.fileName());
117 if(QFile::copy(srcFilepath, destFilePath)==false){ 135 if(QFile::copy(srcFilepath, destFilePath)==false){
118 - qDebug() << srcFilepath << " file copy fail! dest file path info is " << destFilePath; 136 + m_bRst = false;
  137 + emit errorFired(finfo.fileName());
  138 + qDebug() << srcFilepath << " file copy fail!";
  139 + QThread::currentThread()->msleep(5000);
  140 + break;
119 } 141 }
120 nCpyFileSize += finfo.size(); 142 nCpyFileSize += finfo.size();
121 nCurProgress = (nCpyFileSize *100) / nTotalFileSize; 143 nCurProgress = (nCpyFileSize *100) / nTotalFileSize;
@@ -129,7 +151,7 @@ void ProgramCopyWorker::workerMain(){ @@ -129,7 +151,7 @@ void ProgramCopyWorker::workerMain(){
129 } 151 }
130 //QThread::currentThread()->msleep(100); 152 //QThread::currentThread()->msleep(100);
131 } 153 }
132 - if(QThread::currentThread()->isInterruptionRequested()) break; 154 + if(QThread::currentThread()->isInterruptionRequested() || m_bRst == false) break;
133 } 155 }
134 strdirlist.clear(); 156 strdirlist.clear();
135 if(QThread::currentThread()->isInterruptionRequested()) break; 157 if(QThread::currentThread()->isInterruptionRequested()) break;
@@ -137,7 +159,7 @@ void ProgramCopyWorker::workerMain(){ @@ -137,7 +159,7 @@ void ProgramCopyWorker::workerMain(){
137 } 159 }
138 qDebug() << "File Copy Complete! SRC File Size = " << nTotalFileSize << "DEST File Size = " << nCpyFileSize; 160 qDebug() << "File Copy Complete! SRC File Size = " << nTotalFileSize << "DEST File Size = " << nCpyFileSize;
139 161
140 - if(QThread::currentThread()->isInterruptionRequested()){ 162 + if(QThread::currentThread()->isInterruptionRequested() || m_bRst == false){
141 foreach(QString strinfo, m_arrSrcFileList){ 163 foreach(QString strinfo, m_arrSrcFileList){
142 QString filepath = strinfo.left(strinfo.indexOf(',',0)+1); 164 QString filepath = strinfo.left(strinfo.indexOf(',',0)+1);
143 QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1)); 165 QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1));
@@ -540,11 +562,13 @@ void FileProcessDlg::programDownload(){ @@ -540,11 +562,13 @@ void FileProcessDlg::programDownload(){
540 562
541 if(FileProcessor::detectUSB(strDescPath)){ 563 if(FileProcessor::detectUSB(strDescPath)){
542 worker.setDestPath(QString("%1/prime").arg(strDescPath)); 564 worker.setDestPath(QString("%1/prime").arg(strDescPath));
543 - worker.addSrcDir("/prime/cookbook"); 565 + worker.addSrcDir("/prime/history");
  566 + worker.addSrcDir("/prime/program");
544 worker.moveToThread(&programCopyThd); 567 worker.moveToThread(&programCopyThd);
545 568
546 connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain())); 569 connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain()));
547 connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int))); 570 connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int)));
  571 + connect(&worker, SIGNAL(errorFired(QString)), this, SLOT(onErrorFired(QString)));
548 connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop())); 572 connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop()));
549 connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit())); 573 connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit()));
550 connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished())); 574 connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished()));
@@ -564,6 +588,12 @@ void FileProcessDlg::onProgressFinished(){ @@ -564,6 +588,12 @@ void FileProcessDlg::onProgressFinished(){
564 QTimer::singleShot(1000,this, SLOT(close())); 588 QTimer::singleShot(1000,this, SLOT(close()));
565 } 589 }
566 590
  591 +void FileProcessDlg::onErrorFired(QString Desc)
  592 +{
  593 + ui->ctrLbRemainTime->setText(QString("%1 %2").arg(Desc).arg(tr("에러 발생으로 종료합니다.")));
  594 + //QTimer::singleShot(1000,this, SLOT(close()));
  595 +}
  596 +
567 void FileProcessDlg::onProgressed(int progress, int sec){ 597 void FileProcessDlg::onProgressed(int progress, int sec){
568 int min, _sec; 598 int min, _sec;
569 QString strTemp; 599 QString strTemp;
@@ -595,13 +625,14 @@ void FileProcessDlg::programUpload(){ @@ -595,13 +625,14 @@ void FileProcessDlg::programUpload(){
595 worker.addSrcFile(QString("%1/prime/superdaemon.ini.md5,/prime").arg(strSrcPath)); 625 worker.addSrcFile(QString("%1/prime/superdaemon.ini.md5,/prime").arg(strSrcPath));
596 worker.addSrcFile(QString("%1/prime/superdaemon.md5,/prime").arg(strSrcPath)); 626 worker.addSrcFile(QString("%1/prime/superdaemon.md5,/prime").arg(strSrcPath));
597 worker.setDestPath("/prime"); 627 worker.setDestPath("/prime");
598 - worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/cookbook")); 628 + //worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/cookbook")); //쿡북 복사 삭제
599 worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/templates")); 629 worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/templates"));
600 worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/sounds")); 630 worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/sounds"));
601 worker.moveToThread(&programCopyThd); 631 worker.moveToThread(&programCopyThd);
602 632
603 connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain())); 633 connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain()));
604 connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int))); 634 connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int)));
  635 + connect(&worker,SIGNAL(errorFired(QString)),this,SLOT(onErrorFired(QString)));
605 connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop())); 636 connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop()));
606 connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit())); 637 connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit()));
607 connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished())); 638 connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished()));
app/gui/oven_control/fileprocessdlg.h
@@ -41,6 +41,7 @@ public slots: @@ -41,6 +41,7 @@ public slots:
41 signals: 41 signals:
42 void finished(); 42 void finished();
43 void progressed(int progress, int sec); 43 void progressed(int progress, int sec);
  44 + void errorFired(QString Desc);
44 }; 45 };
45 46
46 class FileProcessDlg : public QDialog 47 class FileProcessDlg : public QDialog
@@ -70,6 +71,7 @@ signals: @@ -70,6 +71,7 @@ signals:
70 public slots: 71 public slots:
71 void onProgressed(int progress,int sec); 72 void onProgressed(int progress,int sec);
72 void onProgressFinished(); 73 void onProgressFinished();
  74 + void onErrorFired(QString Desc);
73 75
74 protected: 76 protected:
75 void keyPressEvent(QKeyEvent* event); 77 void keyPressEvent(QKeyEvent* event);