mirror of https://github.com/vitalif/grive2
parent
7e6e153a3a
commit
9c43ad9cc9
|
@ -35,7 +35,6 @@ namespace gr {
|
||||||
|
|
||||||
State::State( const fs::path& filename, const Val& options ) :
|
State::State( const fs::path& filename, const Val& options ) :
|
||||||
m_res ( options["path"].Str() ),
|
m_res ( options["path"].Str() ),
|
||||||
m_dir ( options["dir"].Str() ),
|
|
||||||
m_cstamp ( -1 )
|
m_cstamp ( -1 )
|
||||||
{
|
{
|
||||||
Read( filename ) ;
|
Read( filename ) ;
|
||||||
|
@ -49,6 +48,20 @@ State::State( const fs::path& filename, const Val& options ) :
|
||||||
m_ign = options["ignore"].Str();
|
m_ign = options["ignore"].Str();
|
||||||
force = true;
|
force = true;
|
||||||
}
|
}
|
||||||
|
else if ( options.Has( "dir" ) )
|
||||||
|
{
|
||||||
|
const boost::regex trim_path( "^/+|/+$" );
|
||||||
|
std::string m_dir = regex_replace( options["dir"].Str(), trim_path, "" );
|
||||||
|
if ( !m_dir.empty() )
|
||||||
|
{
|
||||||
|
// "-s" is internally converted to an ignore regexp
|
||||||
|
const boost::regex esc( "[.^$|()\\[\\]{}*+?\\\\]" );
|
||||||
|
std::string ign = "^(?!"+regex_replace( m_dir, esc, "\\\\&", boost::format_sed )+"(/|$))";
|
||||||
|
if ( !m_ign.empty() && ign != m_ign )
|
||||||
|
force = true;
|
||||||
|
m_ign = ign;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// the "-f" option will make grive always think remote is newer
|
// the "-f" option will make grive always think remote is newer
|
||||||
if ( force )
|
if ( force )
|
||||||
|
@ -95,10 +108,6 @@ void State::FromLocal( const fs::path& p, Resource* folder )
|
||||||
if ( IsIgnore( path ) )
|
if ( IsIgnore( path ) )
|
||||||
Log( "file %1% is ignored by grive", path, log::verbose ) ;
|
Log( "file %1% is ignored by grive", path, log::verbose ) ;
|
||||||
|
|
||||||
// check if it is ignored
|
|
||||||
else if ( folder == m_res.Root() && m_dir != "" && fname != m_dir )
|
|
||||||
Log( "%1% %2% is ignored", st.type() == fs::directory_file ? "folder" : "file", fname, log::verbose );
|
|
||||||
|
|
||||||
// check for broken symblic links
|
// check for broken symblic links
|
||||||
else if ( st.type() == fs::file_not_found )
|
else if ( st.type() == fs::file_not_found )
|
||||||
Log( "file %1% doesn't exist (broken link?), ignored", i->path(), log::verbose ) ;
|
Log( "file %1% doesn't exist (broken link?), ignored", i->path(), log::verbose ) ;
|
||||||
|
@ -129,11 +138,8 @@ void State::FromRemote( const Entry& e )
|
||||||
std::string fn = e.Filename() ;
|
std::string fn = e.Filename() ;
|
||||||
std::string k = e.IsDir() ? "folder" : "file";
|
std::string k = e.IsDir() ? "folder" : "file";
|
||||||
|
|
||||||
if ( e.ParentHref() == m_res.Root()->SelfHref() && m_dir != "" && e.Name() != m_dir )
|
|
||||||
Log( "%1% %2% is ignored", k, e.Name(), log::verbose );
|
|
||||||
|
|
||||||
// common checkings
|
// common checkings
|
||||||
else if ( !e.IsDir() && (fn.empty() || e.ContentSrc().empty()) )
|
if ( !e.IsDir() && (fn.empty() || e.ContentSrc().empty()) )
|
||||||
Log( "%1% \"%2%\" is a google document, ignored", k, e.Name(), log::verbose ) ;
|
Log( "%1% \"%2%\" is a google document, ignored", k, e.Name(), log::verbose ) ;
|
||||||
|
|
||||||
else if ( fn.find('/') != fn.npos )
|
else if ( fn.find('/') != fn.npos )
|
||||||
|
|
|
@ -78,7 +78,6 @@ private :
|
||||||
DateTime m_last_sync ;
|
DateTime m_last_sync ;
|
||||||
DateTime m_last_change ;
|
DateTime m_last_change ;
|
||||||
int m_cstamp ;
|
int m_cstamp ;
|
||||||
std::string m_dir ;
|
|
||||||
std::string m_ign ;
|
std::string m_ign ;
|
||||||
boost::regex m_ign_re ;
|
boost::regex m_ign_re ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue