From 842ee98e34051d081a8a6f1514c3b604b948aedf Mon Sep 17 00:00:00 2001
From: IgorekLoschinin <igor.loschinin2014@yandex.ru>
Date: Wed, 9 Jun 2021 21:31:24 +0300
Subject: [PATCH] ref #60 Fixing: added exception messages for method
 processSign.

---
 src/CopyrighFixer/CopyrighFixer/signer.cpp | 37 +++++++++++++---------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/src/CopyrighFixer/CopyrighFixer/signer.cpp b/src/CopyrighFixer/CopyrighFixer/signer.cpp
index 1d81948..464da08 100644
--- a/src/CopyrighFixer/CopyrighFixer/signer.cpp
+++ b/src/CopyrighFixer/CopyrighFixer/signer.cpp
@@ -28,24 +28,32 @@ bool Signer::processSign(const QString &pathToFile, const Config &objConf) const
 
         if (i_file.isDir()) {
             processSign(i_file.filePath(), objConf);
-        }
 
-        IFileManager *currFM = searchFileByExt(i_file.suffix());
-        Signature signFromFile;
-        Signature resultSign;
+        } else {
+            IFileManager *currFM = searchFileByExt(i_file.suffix());
+            Signature signFromFile;
+            Signature resultSign;
 
-        if (currFM == nullptr) {
-            return false;
-        }
+            if (currFM == nullptr) {
+                QuasarAppUtils::Params::log(
+                            QString("The CFixer tool are not support files with sufix: %1").arg(i_file.suffix()),
+                            QuasarAppUtils::VerboseLvl::Error);
+                return false;
+            }
 
-        if (!currFM->read(i_file.filePath(), signFromFile)) {
-            return false;
-        }
+            if (!currFM->read(i_file.filePath(), signFromFile)) {
+                QuasarAppUtils::Params::log(QString("Failed to load file - %1").arg(i_file.fileName()),
+                                            QuasarAppUtils::VerboseLvl::Error);
+                return false;
+            }
 
-        resultSign = mergeSign(objConf.getSignVal(), signFromFile);
+            resultSign = mergeSign(objConf.getSignVal(), signFromFile);
 
-        if (!currFM->write(i_file.filePath(), resultSign)) {
-            return false;
+            if (!currFM->write(i_file.filePath(), resultSign)) {
+                QuasarAppUtils::Params::log(QString("Failed to write signature in file - %1").arg(i_file.fileName()),
+                                            QuasarAppUtils::VerboseLvl::Error);
+                return false;
+            }
         }
     }
 
@@ -67,9 +75,8 @@ const Signature Signer::upgradeOwner(const Signature &signConf, const Signature
 
     Signature signForSing = fileSign;
     QMap<int, CopyrighFixer::Owner> mapOwnersFile = signForSing.getMapOwn();
-    mapOwnersFile.remove(fileSign.getMapOwn().cbegin().key());
 
-    CopyrighFixer::Owner newOwner;
+    CopyrighFixer::Owner newOwner = mapOwnersFile.take(fileSign.getMapOwn().cbegin().key());
     newOwner.setName(signConf.getMapOwn().cbegin().value().getOwnerName());
     newOwner.setTimePoint(unixTime);