]> gitweb.hamatoma.de Git - reqt/commitdiff
ignoring more than 200 errors
authorhama <hama@siduction.net>
Tue, 19 Apr 2016 21:06:37 +0000 (22:06 +0100)
committerhama <hama@siduction.net>
Tue, 19 Apr 2016 21:06:37 +0000 (22:06 +0100)
appl/rebackgui/BackupEngine.cpp
appl/rebackgui/main.cpp
appl/rebackgui/mainwindow.cpp
appl/rebackgui/mainwindow.hpp
appl/rebackgui/mainwindow.ui
base/ReFileUtils.cpp
base/ReFileUtils.hpp
gui/ReGuiQueue.hpp

index f723be562016e740833159ee633b62cd6fcfa69e..eb4f80f8ac4b90a1223fa92d0ea9c7e0cfdcad85 100644 (file)
@@ -231,6 +231,9 @@ void BackupTask::run()
                        else
                                relPath = info.mid(1, pos - 1);
                        node = info.mid(pos + 1);
+                       if (m_searchReady){
+                               m_mainWindow->setLastFile(relPath, node);
+                       }
                        copyFile(index, relPath, node);
                        if (m_verboseLevel > VerboseQuiet){
                                qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch();
@@ -421,6 +424,9 @@ void ChecksumOfTargetTask::run()
                        node = info.mid(pos + 1, pos2 - pos - 1);
                        QString sourceChecksum = info.mid(pos2 + 1);
 
+                       if (m_searchReady){
+                               m_mainWindow->setLastFile(relPath, node);
+                       }
                        QByteArray checksum = buildChecksum(false, index, relPath, node);
                        count++;
                        if (! checksum.isEmpty()){
@@ -486,7 +492,7 @@ void CleanTask::run()
        QString relPath, node;
        QString info;
        QDateTime start = QDateTime::currentDateTime();
-       int processedFiles, hotFiles;
+       int processedFiles = 0, hotFiles = 0;
        while (! m_shouldStop){
                m_mutex.lock();
                if (m_files.size() == 0)
@@ -514,6 +520,8 @@ void CleanTask::run()
                                relPath = info.mid(1, pos - 1);
                        Command command = (Command) info.at(pos + 1).unicode();
                        node = info.mid(pos + 2);
+                       if (m_searchReady)
+                               m_mainWindow->setLastFile(relPath, node);
                        switch(command){
                        case CmdRemove:
                                if (_unlink(I18N::s2b(relPath)) != 0){
@@ -651,6 +659,7 @@ void SearchTask::run()
 void SearchTask::searchOneDirectory(const QString& source,
                                                                         const QString& target, int index){
        QDirIterator it(source);
+       m_mainWindow->setLastDirectory(source);
        QString info, node;
        int lengthBase = m_sourceDirs.at(index).length();
        assert(index < MAX_INDEX);
@@ -673,6 +682,7 @@ void SearchTask::searchOneDirectory(const QString& source,
           }
           it.next();
           node = it.fileName();
+          m_mainWindow->setLastFile(node);
           FILETRACE_IT(s_traceSearch, (s_traceSearch.m_fp, "?%s\n",
                                node.toLocal8Bit().constData()));
           QFileInfo fileInfo = it.fileInfo();
@@ -857,12 +867,14 @@ void SearchTargetTask::searchOneDirectory(const QString& target,
        } else {
                prefix = QChar(1 + index) + m_separatorString;
        }
+       m_mainWindow->setLastDirectory(source);
        while (it.hasNext()){
           if (m_shouldStop){
                  break;
           }
           it.next();
           node = it.fileName();
+          m_mainWindow->setLastFile(node);
           QFileInfo fileInfo = it.fileInfo();
           if (! fileInfo.isSymLink() && fileInfo.isDir()){
                   // nothing to do
index 2c2fcdec9a1bfb7a645518b13110bbfb37122b28..4d9b8a228308fb8cc782a649d7a0be16d17346bc 100644 (file)
@@ -16,6 +16,7 @@
 char** g_argv;
 int main(int argc, char* argv[]) {
        g_argv = argv;
+       ReFileUtils::m_ignoreSetUidError = true;
        QString homeDir = argc > 1 ? argv[1] : "";
        QApplication::setSetuidAllowed(true);
        QApplication a(argc, argv);
index 8489f9ce46fb8cadc77451d656dc9fd43e3f3c96..2050c665f3f4ca925a653ae02b3a648288e4b229 100644 (file)
@@ -37,7 +37,11 @@ MainWindow::MainWindow(QApplication& application, const QString& homeDir,
        m_searchTargetTask(NULL),
        m_cleanTask(NULL),
        m_errors(0),
-       m_maxListSize(1000)
+       m_maxListSize(100),
+       m_mutexLastFile(),
+       m_lastFile(""),
+       m_lastDirectory("")
+
 {
        initializeGui();
 }
@@ -134,7 +138,10 @@ void MainWindow::onGuiTimerUpdate()
                switch(item.m_type){
                case ReGuiQueueItem::ListEnd:
                case ReGuiQueueItem::ListAppendToCurrent:
-                       maxItems = m_maxListSize * 2;
+                       maxItems = m_maxListSize;
+                       break;
+               case ReGuiQueueItem::LogError:
+                       maxItems = max(100, m_maxListSize);
                        break;
                default:
                        break;
@@ -153,7 +160,8 @@ void MainWindow::onGuiTimerUpdate()
                                say(LOG_INFO, item.m_value);
                                break;
                        case ReGuiQueueItem::LogError:
-                               say(LOG_ERROR, item.m_value);
+                               if (m_guiQueue.countOfType(ReGuiQueueItem::LogError) <= maxItems)
+                                       say(LOG_ERROR, item.m_value);
                                break;
                        case ReGuiQueueItem::StatusLine:
                                if (++countStatusMessage % 200 != 0)
@@ -177,6 +185,9 @@ void MainWindow::onGuiTimerUpdate()
                item.apply(m_guiQueue, 0);
                item.m_type = ReGuiQueueItem::Undef;
        }
+       m_mutexLastFile.lock();
+       ui->labelLastFile->setText(m_lastDirectory + m_lastFile);
+       m_mutexLastFile.unlock();
        if (!statusMessage.isEmpty())
                setStatusMessage(LOG_INFO, statusMessage);
 
@@ -380,6 +391,7 @@ void MainWindow::onAutosaveToggled(bool newState){
  * Starts the backup.
  */
 void MainWindow::onChecksums(){
+       setLastFile("", "");
        int row = ui->tableWidget->currentRow();
        if (row < 0){
                say(LOG_ERROR, tr("no backup item selected"));
@@ -414,6 +426,7 @@ void MainWindow::onChecksums(){
  */
 void MainWindow::onClean()
 {
+       setLastFile("", "");
        int row = ui->tableWidget->currentRow();
        if (row < 0){
                say(LOG_ERROR, tr("no backup item selected"));
@@ -607,6 +620,7 @@ void MainWindow::onSelectTarget(){
  * Starts the backup.
  */
 void MainWindow::onStart(){
+       setLastFile("", "");
        int row = ui->tableWidget->currentRow();
        if (row < 0){
                say(LOG_ERROR, tr("no backup item selected"));
@@ -636,6 +650,11 @@ void MainWindow::onStart(){
  */
 void MainWindow::onStop(){
        BackupEngine::m_shouldStop = true;
+       QString message = tr("Aborted by the user");
+       m_mutexGuiQueue.lock();
+       m_guiQueue.clear();
+       m_guiQueue.pushBack(ReGuiQueueItem(ReGuiQueueItem::ReadyMessage, NULL, message));
+       m_mutexGuiQueue.unlock();
 }
 
 /**
@@ -725,6 +744,9 @@ void MainWindow::startStop(bool isStart){
        ui->actionClean->setEnabled(! isStart);
        if (isStart)
                BackupEngine::m_verboseLevel = (ReVerbose_t) ui->comboBoxVerbose->currentIndex();
+       if (! isStart)
+               setStatusMessage(LOG_INFO, "");
+
 }
 
 /**
@@ -747,6 +769,49 @@ void MainWindow::onUpdateConfig(){
        }
 }
 
+/**
+ * Set the last processed file.
+ *
+ * Note: thread safe
+ *
+ * @param lastFile     the last processed file
+ */
+void MainWindow::setLastDirectory(const QString& lastDirectory)
+{
+       m_mutexLastFile.lock();
+       m_lastDirectory = lastDirectory;
+       m_mutexLastFile.unlock();
+}
+
+/**
+ * Set the last processed file.
+ *
+ * Note: thread safe
+ *
+ * @param lastFile     the last processed file
+ */
+void MainWindow::setLastFile(const QString& lastFile)
+{
+       m_mutexLastFile.lock();
+       m_lastFile = lastFile;
+       m_mutexLastFile.unlock();
+}
+
+/**
+ * Set the last processed file.
+ *
+ * Note: thread safe
+ *
+ * @param lastFile     the last processed file
+ */
+void MainWindow::setLastFile(const QString& lastDir, const QString& lastFile)
+{
+       m_mutexLastFile.lock();
+       m_lastFile = lastFile;
+       m_lastDirectory = lastDir;
+       m_mutexLastFile.unlock();
+}
+
 /**
  * Shows the data of a given backup item in the gui elements.
  *
index 6883a4ba1e6ca263cfb5bff32f965b4c28d73e11..0b16df3dc1274672b20ec2fd1387c623d2b09379 100644 (file)
@@ -34,6 +34,9 @@ public:
    virtual bool say(ReLoggerLevel level, const QString& message);
    void startStop(bool isStart);
    void restoreState();
+   void setLastDirectory(const QString& lastFile);
+   void setLastFile(const QString& lastFile);
+   void setLastFile(const QString& lastDir, const QString& lastFile);
    void saveState();
 protected slots:
 private:
@@ -88,6 +91,9 @@ private:
        CleanTask* m_cleanTask;
        int m_errors;
        int m_maxListSize;
+       QMutex m_mutexLastFile;
+       QString m_lastFile;
+       QString m_lastDirectory;
 };
 
 #endif // MAINWINDOW_HPP
index 8fb4ae933015db119e878a3f7a90fb6719c468a0..4beba4990058cff7e433b179df66f8eaa94196c1 100644 (file)
                  <string>Verbose level</string>
                 </property>
                 <property name="currentIndex">
-                 <number>2</number>
+                 <number>1</number>
                 </property>
                 <item>
                  <property name="text">
       </widget>
      </widget>
     </item>
+    <item>
+     <widget class="QLabel" name="labelLastFile">
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+    </item>
    </layout>
   </widget>
   <widget class="QMenuBar" name="menuBar">
      <x>0</x>
      <y>0</y>
      <width>839</width>
-     <height>29</height>
+     <height>31</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
index 6f9b56fe62b638c264036a281facd6e9db8fa26c..f52fe2c18dfb419a469de00fa176b0b4a5e14322 100644 (file)
@@ -22,6 +22,7 @@ enum {
        LOC_SET_TIMES_2,        // 12507
 };
 int ReFileUtils::m_maxCharSet = 128;
+bool ReFileUtils::m_ignoreSetUidError = false;
 
 QDateTime ReFileUtils::m_undefinedTime;
 
@@ -248,8 +249,10 @@ QString ReFileUtils::copy(const QString& source, const QString& target,
 #ifdef __linux__
                        if (setUser){
                                if (chown(target2.constData(), sourceInfo->ownerId(),
-                                                 sourceInfo->groupId()) != 0 && rc.isEmpty()){
-                                       rc = QObject::tr("cannot set user/gid (%1): %2")
+                                                 sourceInfo->groupId()) != 0
+                                               && ! m_ignoreSetUidError && rc.isEmpty()){
+                                       rc = QObject::tr("cannot set user/gid [%1/%2] (%3): %4")
+                                                       .arg(sourceInfo->ownerId()).arg(sourceInfo->groupId())
                                                        .arg(errno).arg(target);
                                }
                        }
index 3c8a7b1048e334f2e115ca559c76635d723cc582..94dc5eaec57f9d5968f632e918f81c772b856e68 100644 (file)
@@ -125,6 +125,7 @@ public:
        static QDateTime m_undefinedTime;
        /// see modifyToNonExisting()
        static int m_maxCharSet;
+       static bool m_ignoreSetUidError;
 };
 
 #endif // REFILEUTILS_HPP
index 4af30aad6942836ea52c9f7e7fde713c89cf79af..a5c0c7cb313ce9e603e6b2519814c0db1fb91488 100644 (file)
@@ -83,9 +83,25 @@ public:
        int count() const;
        ReGuiQueueItem popFront();
        void pushBack(const ReGuiQueueItem& item);
+       /**
+        * Delete all elements.
+        */
+       inline void clear(){
+               QList::clear();
+       }
+       /**
+        * Returns the count of items with a given type
+        * @param type  the type to search
+        * @return  the count of items with a given type
+        */
        inline int countOfType(ReGuiQueueItem::WidgetType type) const {
                return m_countOfType[type];
        }
+       /**
+        * Returns the last of the items with a given type read from the queue.
+        * @param type  the type to search
+        * @return  the last of the items with a given type read from the queue
+        */
        inline ReGuiQueueItem& lastOfType(ReGuiQueueItem::WidgetType type){
                return m_lastOfType[type];
        }