mirror of https://github.com/vitalif/grive2
Implement upload-only and no-remote-new modes (fix #69)
parent
cfb8ff08b3
commit
40e33cb524
|
@ -70,6 +70,10 @@ Enjoy!
|
|||
|
||||
## Version History
|
||||
|
||||
### Grive2 v0.5.1-dev
|
||||
|
||||
- no-remote-new and upload-only modes
|
||||
|
||||
### Grive2 v0.5
|
||||
|
||||
- Much faster and more correct synchronisation using local modification time and checksum cache (similar to git index)
|
||||
|
|
|
@ -33,6 +33,16 @@ Forces
|
|||
.I grive
|
||||
to always download a file from Google Drive instead uploading it
|
||||
.TP
|
||||
\fB\-u, \-\-upload\-only\fR
|
||||
Forces
|
||||
.I grive
|
||||
to not download anything from Google Drive and only upload local changes to server instead
|
||||
.TP
|
||||
\fB\-n, \-\-no\-remote\-new\fR
|
||||
Forces
|
||||
.I grive
|
||||
to download only files that are changed in Google Drive and already exist locally
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Produces help message
|
||||
.TP
|
||||
|
|
|
@ -118,6 +118,8 @@ int Main( int argc, char **argv )
|
|||
( "log,l", po::value<std::string>(), "Set log output filename." )
|
||||
( "force,f", "Force grive to always download a file from Google Drive "
|
||||
"instead of uploading it." )
|
||||
( "upload-only,u", "Do not download anything from Google Drive, only upload local changes" )
|
||||
( "no-remote-new,n", "Download only files that are changed in Google Drive and already exist locally" )
|
||||
( "dry-run", "Only detect which files need to be uploaded/downloaded, "
|
||||
"without actually performing them." )
|
||||
( "ignore", po::value<std::string>(), "Perl RegExp to ignore files (matched against relative paths, remembered for next runs)." )
|
||||
|
|
|
@ -542,26 +542,36 @@ void Resource::SyncSelf( Syncer* syncer, ResourceTree *res_tree, const Val& opti
|
|||
break ;
|
||||
|
||||
case remote_new :
|
||||
Log( "sync %1% created in remote. creating local", path, log::info ) ;
|
||||
if ( syncer )
|
||||
if ( options["no-remote-new"].Bool() )
|
||||
Log( "sync %1% created in remote. skipping", path, log::info ) ;
|
||||
else
|
||||
{
|
||||
if ( IsFolder() )
|
||||
fs::create_directories( path ) ;
|
||||
else
|
||||
syncer->Download( this, path ) ;
|
||||
SetIndex( true ) ;
|
||||
m_state = sync ;
|
||||
Log( "sync %1% created in remote. creating local", path, log::info ) ;
|
||||
if ( syncer )
|
||||
{
|
||||
if ( IsFolder() )
|
||||
fs::create_directories( path ) ;
|
||||
else
|
||||
syncer->Download( this, path ) ;
|
||||
SetIndex( true ) ;
|
||||
m_state = sync ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
|
||||
case remote_changed :
|
||||
assert( !IsFolder() ) ;
|
||||
Log( "sync %1% changed in remote. downloading", path, log::info ) ;
|
||||
if ( syncer )
|
||||
if ( options["upload-only"].Bool() )
|
||||
Log( "sync %1% changed in remote. skipping", path, log::info ) ;
|
||||
else
|
||||
{
|
||||
syncer->Download( this, path ) ;
|
||||
SetIndex( true ) ;
|
||||
m_state = sync ;
|
||||
Log( "sync %1% changed in remote. downloading", path, log::info ) ;
|
||||
if ( syncer )
|
||||
{
|
||||
syncer->Download( this, path ) ;
|
||||
SetIndex( true ) ;
|
||||
m_state = sync ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
|
||||
|
|
|
@ -46,8 +46,10 @@ Config::Config( const po::variables_map& vm )
|
|||
m_cmd.Add( "dir", Val(vm.count("dir") > 0
|
||||
? vm["dir"].as<std::string>()
|
||||
: "" ) ) ;
|
||||
if ( vm.count("ignore") > 0 )
|
||||
if ( vm.count( "ignore" ) > 0 )
|
||||
m_cmd.Add( "ignore", Val( vm["ignore"].as<std::string>() ) );
|
||||
m_cmd.Add( "no-remote-new", Val( vm.count( "no-remote-new" ) > 0 || vm.count( "upload-only" ) > 0 ) );
|
||||
m_cmd.Add( "upload-only", Val( vm.count( "upload-only" ) > 0 ) );
|
||||
|
||||
m_path = GetPath( fs::path(m_cmd["path"].Str()) ) ;
|
||||
m_file = Read( ) ;
|
||||
|
|
Loading…
Reference in New Issue