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))
{
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();
}
}
+
//=====================================================================
void TreeHandlerImageAdder::AddDirectoryRecursor(const std::string &dirpath,
bool recursive,
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()) )
{
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();
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);
}
}
- mTimestampHandler->SetAttribute("TopLevelNodeId",parent_id,"PATH",dirpath);
}
}
//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;
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;
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;
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+"%");