mirror of https://github.com/vitalif/grive2
recursively sync the resources
parent
7be193c35b
commit
991d8e444f
|
@ -37,6 +37,7 @@
|
|||
#include "xml/NodeSet.hh"
|
||||
#include "xml/String.hh"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/exception/all.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
@ -340,14 +341,16 @@ Resource* Resource::FindChild( const std::string& name )
|
|||
void Resource::Sync( http::Agent *http, const http::Header& auth )
|
||||
{
|
||||
assert( m_state != unknown ) ;
|
||||
|
||||
// root folder is already synced
|
||||
if ( IsRoot() )
|
||||
{
|
||||
assert( m_state == sync ) ;
|
||||
return ;
|
||||
}
|
||||
assert( !IsRoot() || m_state == sync ) ; // root folder is already synced
|
||||
|
||||
SyncSelf( http, auth ) ;
|
||||
|
||||
std::for_each( m_child.begin(), m_child.end(),
|
||||
boost::bind( &Resource::Sync, _1, http, auth ) ) ;
|
||||
}
|
||||
|
||||
void Resource::SyncSelf( http::Agent* http, const http::Header& auth )
|
||||
{
|
||||
switch ( m_state )
|
||||
{
|
||||
case local_new :
|
||||
|
@ -393,6 +396,10 @@ void Resource::Sync( http::Agent *http, const http::Header& auth )
|
|||
case sync :
|
||||
Log( "sync %1% already in sync", Path(), log::verbose ) ;
|
||||
break ;
|
||||
|
||||
case unknown :
|
||||
assert( false ) ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
break ;
|
||||
|
|
|
@ -134,6 +134,7 @@ private :
|
|||
void DeleteRemote( http::Agent* http, const http::Header& auth ) ;
|
||||
|
||||
void AssignIDs( const Entry& remote ) ;
|
||||
void SyncSelf( http::Agent* http, const http::Header& auth ) ;
|
||||
|
||||
private :
|
||||
std::string m_name ;
|
||||
|
|
|
@ -29,14 +29,6 @@
|
|||
#include "util/log/Log.hh"
|
||||
#include "protocol/Json.hh"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
#include <boost/multi_index/identity.hpp>
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/multi_index/mem_fun.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace gr {
|
||||
|
@ -260,9 +252,7 @@ void State::Write( const fs::path& filename ) const
|
|||
|
||||
void State::Sync( http::Agent *http, const http::Header& auth )
|
||||
{
|
||||
std::for_each( m_res.begin(), m_res.end(),
|
||||
boost::bind( &Resource::Sync, _1, http, auth ) ) ;
|
||||
|
||||
m_res.Root()->Sync( http, auth ) ;
|
||||
m_last_sync = DateTime::Now() ;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue