mirror of https://github.com/vitalif/grive2
Merge branch 'v0.0.4' into working
commit
ba737cba29
|
@ -183,7 +183,8 @@ std::cout << "local " << path << " is newer" << std::endl ;
|
||||||
// re-reading the file
|
// re-reading the file
|
||||||
ifile.seekg(0) ;
|
ifile.seekg(0) ;
|
||||||
|
|
||||||
file.Upload( ifile.rdbuf(), m_http_hdr ) ;
|
if ( !file.Upload( ifile.rdbuf(), m_http_hdr ) )
|
||||||
|
std::cout << path << " is read only" << std::endl ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,9 @@ void File::Update( const Json& entry )
|
||||||
FindInArray( "scheme", "http://schemas.google.com/g/2005#kind", node )
|
FindInArray( "scheme", "http://schemas.google.com/g/2005#kind", node )
|
||||||
? node["label"].Str() : std::string() ;
|
? node["label"].Str() : std::string() ;
|
||||||
|
|
||||||
m_upload_link = entry["link"].FindInArray( "rel",
|
m_upload_link = entry["link"].
|
||||||
"http://schemas.google.com/g/2005#resumable-edit-media" )["href"].Str() ;
|
FindInArray( "rel", "http://schemas.google.com/g/2005#resumable-edit-media", node )
|
||||||
|
? node["href"].Str() : std::string() ;
|
||||||
|
|
||||||
// convert to lower case for easy comparison
|
// convert to lower case for easy comparison
|
||||||
std::transform(
|
std::transform(
|
||||||
|
@ -115,8 +116,12 @@ void File::Download( const Path& file, const http::Headers& auth ) const
|
||||||
os::SetFileTime( file, m_server_modified ) ;
|
os::SetFileTime( file, m_server_modified ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::Upload( std::streambuf *file, const http::Headers& auth )
|
bool File::Upload( std::streambuf *file, const http::Headers& auth )
|
||||||
{
|
{
|
||||||
|
// upload link missing means that file is read only
|
||||||
|
if ( m_upload_link.empty() )
|
||||||
|
return false ;
|
||||||
|
|
||||||
std::string meta =
|
std::string meta =
|
||||||
"<?xml version='1.0' encoding='UTF-8'?>\n"
|
"<?xml version='1.0' encoding='UTF-8'?>\n"
|
||||||
"<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:docs=\"http://schemas.google.com/docs/2007\">"
|
"<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:docs=\"http://schemas.google.com/docs/2007\">"
|
||||||
|
@ -148,6 +153,7 @@ void File::Upload( std::streambuf *file, const http::Headers& auth )
|
||||||
uphdr.push_back( "Accept:" ) ;
|
uphdr.push_back( "Accept:" ) ;
|
||||||
|
|
||||||
http.Put( http.RedirLocation(), data, uphdr ) ;
|
http.Put( http.RedirLocation(), data, uphdr ) ;
|
||||||
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace
|
} // end of namespace
|
||||||
|
|
|
@ -48,7 +48,7 @@ public :
|
||||||
std::string Parent() const ;
|
std::string Parent() const ;
|
||||||
|
|
||||||
void Download( const Path& file, const http::Headers& auth ) const ;
|
void Download( const Path& file, const http::Headers& auth ) const ;
|
||||||
void Upload( std::streambuf *file, const http::Headers& auth ) ;
|
bool Upload( std::streambuf *file, const http::Headers& auth ) ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
void Update( const Json& entry ) ;
|
void Update( const Json& entry ) ;
|
||||||
|
|
Loading…
Reference in New Issue