Commit 7835a65554994a74bb9c3a12dd0d6f11c4a6b4a9
1 parent
1342af7b38
Exists in
master
and in
2 other branches
파일 복사 기능 수정
- 복사 실패 시 복원
Showing
2 changed files
with
41 additions
and
8 deletions
Show diff stats
app/gui/oven_control/fileprocessdlg.cpp
... | ... | @@ -37,6 +37,7 @@ void ProgramCopyWorker::workerMain(){ |
37 | 37 | QStringList strdirlist; |
38 | 38 | QString srcFilepath; |
39 | 39 | QString destFilePath; |
40 | + bool m_bRst=true; | |
40 | 41 | |
41 | 42 | //make destination folder |
42 | 43 | QDir destdir(m_strDestDir); |
... | ... | @@ -58,8 +59,10 @@ void ProgramCopyWorker::workerMain(){ |
58 | 59 | } |
59 | 60 | qDebug() << " Dir List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize; |
60 | 61 | if(nTotalFileSize <=0 ){ |
62 | + emit errorFired("SIZE ERROR "); | |
63 | + QThread::currentThread()->msleep(5000); | |
61 | 64 | emit finished(); |
62 | - progressed(0,0); | |
65 | + emit progressed(0,0); | |
63 | 66 | return; |
64 | 67 | } |
65 | 68 | |
... | ... | @@ -75,7 +78,13 @@ void ProgramCopyWorker::workerMain(){ |
75 | 78 | if(QFile::exists(destFilePath)){ |
76 | 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 | 88 | nCpyFileSize += finfo.size(); |
80 | 89 | nCurProgress = (nCpyFileSize *100) / nTotalFileSize; |
81 | 90 | nRemainSec = (nTotalFileSize-nCpyFileSize)/200000; |
... | ... | @@ -87,13 +96,22 @@ void ProgramCopyWorker::workerMain(){ |
87 | 96 | } |
88 | 97 | QThread::currentThread()->msleep(10); |
89 | 98 | } |
99 | + | |
90 | 100 | qDebug() << "File List Copy Finished"; |
91 | 101 | |
92 | - if(QThread::currentThread()->isInterruptionRequested() == false){ | |
102 | + if(QThread::currentThread()->isInterruptionRequested() == false || m_bRst == false){ | |
93 | 103 | foreach(QString srcpath, m_arrSrcDirList){ |
94 | 104 | qDebug() << "src dir : " << srcpath; |
95 | 105 | |
96 | 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 | 115 | strdirlist.append(srcpath); |
98 | 116 | FileProcessor::getAllDirList(srcdir, strdirlist); |
99 | 117 | qDebug() << "dir size : " <<strdirlist.size(); |
... | ... | @@ -115,7 +133,11 @@ void ProgramCopyWorker::workerMain(){ |
115 | 133 | srcFilepath = finfo.absoluteFilePath(); |
116 | 134 | destFilePath = QString("%1/%2").arg(QString(strDir).replace(srcpath,targetpath)).arg(finfo.fileName()); |
117 | 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 | 142 | nCpyFileSize += finfo.size(); |
121 | 143 | nCurProgress = (nCpyFileSize *100) / nTotalFileSize; |
... | ... | @@ -129,7 +151,7 @@ void ProgramCopyWorker::workerMain(){ |
129 | 151 | } |
130 | 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 | 156 | strdirlist.clear(); |
135 | 157 | if(QThread::currentThread()->isInterruptionRequested()) break; |
... | ... | @@ -137,7 +159,7 @@ void ProgramCopyWorker::workerMain(){ |
137 | 159 | } |
138 | 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 | 163 | foreach(QString strinfo, m_arrSrcFileList){ |
142 | 164 | QString filepath = strinfo.left(strinfo.indexOf(',',0)+1); |
143 | 165 | QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1)); |
... | ... | @@ -540,11 +562,13 @@ void FileProcessDlg::programDownload(){ |
540 | 562 | |
541 | 563 | if(FileProcessor::detectUSB(strDescPath)){ |
542 | 564 | worker.setDestPath(QString("%1/prime").arg(strDescPath)); |
543 | - worker.addSrcDir("/prime/cookbook"); | |
565 | + worker.addSrcDir("/prime/history"); | |
566 | + worker.addSrcDir("/prime/program"); | |
544 | 567 | worker.moveToThread(&programCopyThd); |
545 | 568 | |
546 | 569 | connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain())); |
547 | 570 | connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int))); |
571 | + connect(&worker, SIGNAL(errorFired(QString)), this, SLOT(onErrorFired(QString))); | |
548 | 572 | connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop())); |
549 | 573 | connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit())); |
550 | 574 | connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished())); |
... | ... | @@ -564,6 +588,12 @@ void FileProcessDlg::onProgressFinished(){ |
564 | 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 | 597 | void FileProcessDlg::onProgressed(int progress, int sec){ |
568 | 598 | int min, _sec; |
569 | 599 | QString strTemp; |
... | ... | @@ -595,13 +625,14 @@ void FileProcessDlg::programUpload(){ |
595 | 625 | worker.addSrcFile(QString("%1/prime/superdaemon.ini.md5,/prime").arg(strSrcPath)); |
596 | 626 | worker.addSrcFile(QString("%1/prime/superdaemon.md5,/prime").arg(strSrcPath)); |
597 | 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 | 629 | worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/templates")); |
600 | 630 | worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/sounds")); |
601 | 631 | worker.moveToThread(&programCopyThd); |
602 | 632 | |
603 | 633 | connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain())); |
604 | 634 | connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int))); |
635 | + connect(&worker,SIGNAL(errorFired(QString)),this,SLOT(onErrorFired(QString))); | |
605 | 636 | connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop())); |
606 | 637 | connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit())); |
607 | 638 | connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished())); | ... | ... |
app/gui/oven_control/fileprocessdlg.h
... | ... | @@ -41,6 +41,7 @@ public slots: |
41 | 41 | signals: |
42 | 42 | void finished(); |
43 | 43 | void progressed(int progress, int sec); |
44 | + void errorFired(QString Desc); | |
44 | 45 | }; |
45 | 46 | |
46 | 47 | class FileProcessDlg : public QDialog |
... | ... | @@ -70,6 +71,7 @@ signals: |
70 | 71 | public slots: |
71 | 72 | void onProgressed(int progress,int sec); |
72 | 73 | void onProgressFinished(); |
74 | + void onErrorFired(QString Desc); | |
73 | 75 | |
74 | 76 | protected: |
75 | 77 | void keyPressEvent(QKeyEvent* event); | ... | ... |