diff --git a/libgrive/src/drive/Collection.cc b/libgrive/src/drive/Collection.cc index 68a5593..9bf7899 100644 --- a/libgrive/src/drive/Collection.cc +++ b/libgrive/src/drive/Collection.cc @@ -45,7 +45,7 @@ Collection::Collection( { } -std::string Collection::Href() const +std::string Collection::SelfHref() const { return m_entry.SelfHref() ; } diff --git a/libgrive/src/drive/Collection.hh b/libgrive/src/drive/Collection.hh index 082fb44..d8b127c 100644 --- a/libgrive/src/drive/Collection.hh +++ b/libgrive/src/drive/Collection.hh @@ -42,7 +42,7 @@ public : static bool IsCollection( const xml::Node& entry ) ; std::string Title() const ; - std::string Href() const ; + std::string SelfHref() const ; const Collection* Parent() const ; Collection* Parent() ; std::string ParentHref() const ; diff --git a/libgrive/src/drive/CommonUri.hh b/libgrive/src/drive/CommonUri.hh index dd619d7..a086c42 100644 --- a/libgrive/src/drive/CommonUri.hh +++ b/libgrive/src/drive/CommonUri.hh @@ -23,5 +23,8 @@ namespace gr { - const std::string root_url = "https://docs.google.com/feeds/default/private/full" ; + const std::string feed_base = "https://docs.google.com/feeds/default/private/full" ; + + const std::string root_href = + "https://docs.google.com/feeds/default/private/full/folder%3Aroot" ; } diff --git a/libgrive/src/drive/Drive.cc b/libgrive/src/drive/Drive.cc index 51aee9e..40c6f76 100644 --- a/libgrive/src/drive/Drive.cc +++ b/libgrive/src/drive/Drive.cc @@ -47,7 +47,7 @@ namespace gr { Drive::Drive( OAuth2& auth ) : m_auth( auth ), - m_root( ".", "https://docs.google.com/feeds/default/private/full/folder%3Aroot" ) + m_root( ".", root_href ) { m_http_hdr.push_back( "Authorization: Bearer " + m_auth.AccessToken() ) ; m_http_hdr.push_back( "GData-Version: 3.0" ) ; @@ -58,7 +58,7 @@ Drive::Drive( OAuth2& auth ) : http::XmlResponse xrsp ; http::ResponseLog log( "first-", ".xml", &xrsp ) ; - http.Get( root_url + "?showfolders=true", &log, m_http_hdr ) ; + http.Get( feed_base + "?showfolders=true", &log, m_http_hdr ) ; xml::Node resp = xrsp.Response() ; m_resume_link = resp["link"]. @@ -95,7 +95,7 @@ struct SortCollectionByHref { bool operator()( const Collection& c1, const Collection& c2 ) const { - return c1.Href() < c2.Href() ; + return c1.SelfHref() < c2.SelfHref() ; } } ; @@ -109,7 +109,7 @@ Drive::FolderListIterator Drive::FindFolder( const std::string& href ) Collection( "", href ), SortCollectionByHref() ) ; - return (it != m_coll.end() && it->Href() == href) ? it : m_coll.end() ; + return (it != m_coll.end() && it->SelfHref() == href) ? it : m_coll.end() ; } void Drive::ConstructDirTree( http::Agent *http ) @@ -117,7 +117,7 @@ void Drive::ConstructDirTree( http::Agent *http ) http::XmlResponse xml ; http::ResponseLog log( "dir-", ".xml", &xml ) ; - http->Get( root_url + "/-/folder?max-results=10", &log, m_http_hdr ) ; + http->Get( feed_base + "/-/folder?max-results=10&showroot=true", &log, m_http_hdr ) ; xml::Node resp = xml.Response() ; @@ -147,6 +147,10 @@ void Drive::ConstructDirTree( http::Agent *http ) for ( FolderListIterator i = m_coll.begin() ; i != m_coll.end() ; ++i ) { if ( i->ParentHref().empty() ) + { + std::cout << "folder \"" << i->Title() << "\" not in root folder, ignored" << std::endl ; + } + else if ( i->ParentHref() == root_href ) m_root.AddChild( &*i ) ; else { @@ -161,6 +165,8 @@ void Drive::ConstructDirTree( http::Agent *http ) else pit->AddChild( &*i ) ; } + else + std::cout << "can't find folder " << i->Title() << " " << i->ParentHref() << std::endl ; } } diff --git a/libgrive/src/drive/Entry.cc b/libgrive/src/drive/Entry.cc index 1a62273..0f9bf60 100644 --- a/libgrive/src/drive/Entry.cc +++ b/libgrive/src/drive/Entry.cc @@ -191,10 +191,10 @@ void Entry::Delete( http::Agent *http, const http::Headers& auth ) http::Headers hdr( auth ) ; hdr.push_back( "If-Match: " + m_etag ) ; -std::cout << root_url + "/" + m_resource_id + "?delete=true" << std::endl ; +std::cout << feed_base + "/" + m_resource_id + "?delete=true" << std::endl ; http::StringResponse str ; - http->Custom( "DELETE", root_url + "/" + m_resource_id + "?delete=true", &str, hdr ) ; + http->Custom( "DELETE", feed_base + "/" + m_resource_id + "?delete=true", &str, hdr ) ; } void Entry::Swap( Entry& e )