DB detected item cleanup only when history exist 24/71324/2
authorKyungwook Tak <k.tak@samsung.com>
Wed, 25 May 2016 04:50:56 +0000 (13:50 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Wed, 25 May 2016 05:47:50 +0000 (14:47 +0900)
When scan heavily at first time, it's too much overhead.
Delete item only when needed.

Change-Id: Iefa55b5e9b04f9a3eb5ea25007b1ee6e42690bfd
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/service/cs-logic.cpp

index 1944c6f..b95658c 100644 (file)
@@ -122,19 +122,23 @@ CsDetectedPtr CsLogic::scanAppDelta(const std::string &pkgPath, const std::strin
        CsEngineContext engineContext(this->m_loader);
        auto &c = engineContext.get();
 
+       auto lastScanTime = this->m_db.getLastScanTime(pkgPath, this->m_dataVersion);
+
        // traverse files in app and take which is more danger than riskiest
-       auto visitor = FsVisitor::create(
-                                          pkgPath,
-                                          this->m_db.getLastScanTime(pkgPath, this->m_dataVersion));
+       auto visitor = FsVisitor::create(pkgPath, lastScanTime);
 
        CsDetectedPtr riskiest;
 
        while (auto file = visitor->next()) {
+               DEBUG("Scan file by engine: " << file->getPath());
+
                csre_cs_detected_h result;
                toException(this->m_loader.scanFile(c, file->getPath(), &result));
 
                if (!result) {
-                       this->m_db.deleteDetectedByFilepathOnPath(file->getPath());
+                       if (lastScanTime != -1)
+                               this->m_db.deleteDetectedByFilepathOnPath(file->getPath());
+
                        continue;
                }