fixed assertion if remote has dot file (#43)

pull/40/head
Nestal Wan 2012-06-06 23:35:29 +08:00
parent 856914c4dc
commit c81bb0aaec
5 changed files with 25 additions and 7 deletions

View File

@ -220,4 +220,9 @@ bool Entry::IsRemoved() const
return m_is_removed ;
}
std::string Entry::Name() const
{
return m_kind == "folder" ? m_title : m_filename ;
}
} // end of namespace

View File

@ -64,6 +64,8 @@ public :
std::string ContentSrc() const ;
std::string EditLink() const ;
std::string CreateLink() const ;
long ChangeStamp() const ;
bool IsRemoved() const ;
const std::vector<std::string>& ParentHrefs() const ;
@ -72,9 +74,7 @@ public :
void Update( const xml::Node& entry ) ;
void Update( const std::string& md5, const DateTime& mtime ) ;
long ChangeStamp() const ;
bool IsRemoved() const ;
std::string Name() const ;
private :
std::string m_title ;

View File

@ -228,7 +228,7 @@ std::string Resource::SelfHref() const
std::string Resource::Name() const
{
return IsFolder() ? m_entry.Title() : m_entry.Filename() ;
return m_entry.Name() ;
}
std::string Resource::ResourceID() const

View File

@ -59,6 +59,11 @@ void State::FromLocal( const fs::path& p )
FromLocal( p, m_res.Root() ) ;
}
bool State::IsIgnore( const std::string& filename )
{
return filename[0] == '.' ;
}
void State::FromLocal( const fs::path& p, gr::Resource* folder )
{
assert( folder != 0 ) ;
@ -71,7 +76,7 @@ void State::FromLocal( const fs::path& p, gr::Resource* folder )
{
std::string fname = i->path().filename().string() ;
if ( fname[0] == '.' )
if ( IsIgnore(fname) )
Log( "file %1% is ignored by grive", fname, log::verbose ) ;
else
@ -96,7 +101,10 @@ void State::FromLocal( const fs::path& p, gr::Resource* folder )
void State::FromRemote( const Entry& e )
{
if ( !Update( e ) )
if ( IsIgnore( e.Name() ) )
Log( "%1% %2% is ignored by grive", e.Kind(), e.Name(), log::verbose ) ;
else if ( !Update( e ) )
{
m_unresolved.push_back( e ) ;
}
@ -133,9 +141,12 @@ std::size_t State::TryResolveEntry()
void State::FromChange( const Entry& e )
{
if ( IsIgnore( e.Name() ) )
Log( "%1% %2% is ignored by grive", e.Kind(), e.Name(), log::verbose ) ;
// entries in the change feed is always treated as newer in remote,
// so we override the last sync time to 0
if ( Resource *res = m_res.FindByHref( e.AltSelf() ) )
else if ( Resource *res = m_res.FindByHref( e.AltSelf() ) )
m_res.Update( res, e, DateTime() ) ;
}

View File

@ -71,6 +71,8 @@ private :
bool Update( const Entry& e ) ;
std::size_t TryResolveEntry() ;
static bool IsIgnore( const std::string& filename ) ;
private :
ResourceTree m_res ;
DateTime m_last_sync ;