]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOTreeHandlerImageAdder.cpp
Remove timestamp_database and timestamp files (now management only with maintenance_d...
[creaImageIO.git] / src2 / creaImageIOTreeHandlerImageAdder.cpp
index ad88ef77abb5d800743a1a64097ac54126cd0a10..b1a60437cd2fa22737e4f1bd0b0fd2e339c4a273 100644 (file)
@@ -50,7 +50,7 @@ namespace creaImageIO
     std::vector<std::string>::const_iterator i;
     for (i=filenames.begin();i!=filenames.end();++i)
       {
-       mTimestampHandler->AddFile((*i), fs::last_write_time(*i), time(0),mCurrentDB);
+       
        mProgress.IncNumberScannedFiles();
        if (IsHandledFile(*i)) 
          {
@@ -80,6 +80,7 @@ namespace creaImageIO
        mSynchronizer->InsertAddOp(directory,rec.str(),"0",mCurrentDB);
        std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",directory,mCurrentDB);
        mTreeHandler->BeginTransaction();
+       mSynchronizer->GetList();
        AddDirectoryRecursor( directory, recurse, addKey );
        
        int nFiles=GetProgress().GetNumberAddedFiles();
@@ -161,6 +162,7 @@ namespace creaImageIO
          }
   }
 
   //=====================================================================
   void TreeHandlerImageAdder::AddDirectoryRecursor(const std::string &dirpath, 
                                                   bool recursive,
@@ -172,11 +174,12 @@ namespace creaImageIO
     if ( !fs::exists( dirpath ) ) return;
        time_t lastModif=fs::last_write_time(dirpath);
 
+       
     fs::directory_iterator end_itr; // default construction yields past-the-end
     for ( fs::directory_iterator itr( dirpath );
          itr != end_itr;
          ++itr )
-      {
+       {
        // If is directory & recurse : do recurse
        if ( fs::is_directory(itr->status()) )
          {
@@ -188,7 +191,8 @@ namespace creaImageIO
        else 
          {
                std::string parent_id;
-               bool valid=mTimestampHandler->AddDirectory(dirpath, itr->string(), lastModif, time(0),mCurrentDB);
+               // tTest if directory (and only it) exists or not.
+               bool valid = mSynchronizer->isIndexed(itr->string());//true;//=mTimestampHandler->AddDirectory(dirpath, itr->string(), lastModif, time(0),mCurrentDB);
                if(valid)
                {
                        mProgress.IncNumberScannedFiles();
@@ -197,7 +201,6 @@ namespace creaImageIO
                        mProgress.IncNumberHandledFiles();
                        AddFile( itr->string() );
                        mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id);
-                       mTimestampHandler->SetAttribute("TopLevelNodeId",parent_id,"PATH",itr->string());
                        std::stringstream removedOn;
                        removedOn<<time(0);
                        mSynchronizer->InsertIgnoreFile(addKey, itr->string(),"0",removedOn.str(),mCurrentDB);
@@ -211,7 +214,6 @@ namespace creaImageIO
                        }
                        
                }
-               mTimestampHandler->SetAttribute("TopLevelNodeId",parent_id,"PATH",dirpath);
          }
       }
        
@@ -352,7 +354,6 @@ namespace creaImageIO
                        //For the new files, add them
                        for (i=newFiles.begin();i!=newFiles.end();++i)
                        {
-                       mTimestampHandler->AddFile((*i), fs::last_write_time(*i), time(0),mCurrentDB);
                        if (IsHandledFile(*i)) 
                        {
                                std::stringstream removedOn;
@@ -487,17 +488,14 @@ namespace creaImageIO
          if(!boost::filesystem::exists(directory))
          {
          boost::filesystem::create_directory(boost::filesystem::path(directory));
-         mTimestampHandler->AddDirectory("",directory,fs::last_write_time(directory)+10, time(0),mCurrentDB);
          mSynchronizer->InsertAddOp(directory,"0","0",mCurrentDB);
          }
          std::string addKey=mSynchronizer->GetAttribute("ADD_KEY","ADD_OPS","PATH",directory,mCurrentDB);
-         std::string parent_id=mTimestampHandler->IsIndexed(directory,mCurrentDB);
          size_t last;
          std::vector<std::string> newNames;
          for(i=filenames.begin();i!=filenames.end();++i)
          {
                  std::string dir=directory.c_str();
-                 mTimestampHandler->CleanPath(dir);
                  if(boost::filesystem::exists(*i) && (*i).find(dir)==std::string::npos)
                  {
                  std::string path=*i;
@@ -514,19 +512,11 @@ namespace creaImageIO
                          p++;
                  }
                  std::string result=out.str();
-                 mTimestampHandler->CleanPath(result);
                  boost::filesystem::copy_file((*i),result);
 
                  //To update image database
                  mTreeHandler->SetAttribute("Image","FullFileName",result,"FullFileName", (*i));
                  
-                 //To update timestamp database
-                 mTimestampHandler->SetAttribute("PATH",result,"PATH",(*i));
-                 mTimestampHandler->SetAttribute("PARENT_ID",parent_id,"PATH",result);
-                 std::stringstream t;
-                 t<<fs::last_write_time(directory)+10;
-                 mTimestampHandler->SetAttribute("LastModified",t.str(),"PATH",result);
-
                  //To update maintenance database
                  //1.Add the new path and increase number of children on new operation.
                  std::stringstream removedOn;
@@ -580,9 +570,6 @@ namespace creaImageIO
 
   void TreeHandlerImageAdder::DeleteDriveFromOtherDB(const std::string& drive)
   {
-         //Delete from timestamp
-         mTimestampHandler->RemoveEntries("FILES", "PATH", "LIKE", drive+"%");
-
          //Delete from maintenance
          mSynchronizer->RemoveEntries("ADD_OPS", "PATH", "LIKE", drive+"%");
          mSynchronizer->RemoveEntries("IGNORED_FILES", "PATH", "LIKE", drive+"%");