Fixed indents

pull/36/head
Dylan Wulf 2015-10-12 16:32:19 -04:00
parent 4a8cbc02ef
commit 27ce2df4e5
10 changed files with 65 additions and 65 deletions

View File

@ -121,7 +121,7 @@ int Main( int argc, char **argv )
( "dry-run", "Only detect which files need to be uploaded/downloaded, "
"without actually performing them." )
( "ignore", po::value<std::string>(), "Ignore files relative paths of which match this Perl RegExp." )
( "move,m", po::value<std::vector<std::string> >()->multitoken(), "Moves or renames a file without reuploading or redownloading." )
( "move,m", po::value<std::vector<std::string> >()->multitoken(), "Moves or renames a file without reuploading or redownloading." )
;
po::variables_map vm;
@ -202,15 +202,15 @@ int Main( int argc, char **argv )
drive.Update() ;
drive.SaveState() ;
}
else if ( vm.count( "move" ) > 0 )
{
bool success = drive.Move( vm["move"].as<std::vector<std::string> >()[0],
vm["move"].as<std::vector<std::string> >()[1] );
if (success)
Log( "Move successful!", log::info );
else
Log( "Move failed.", log::error);
}
else if ( vm.count( "move" ) > 0 )
{
bool success = drive.Move( vm["move"].as<std::vector<std::string> >()[0],
vm["move"].as<std::vector<std::string> >()[1] );
if (success)
Log( "Move successful!", log::info );
else
Log( "Move failed.", log::error);
}
else
drive.DryRun() ;

View File

@ -152,14 +152,14 @@ void Drive::DetectChanges()
bool Drive::Move( fs::path old_p, fs::path new_p )
{
return m_state.Move( m_syncer, old_p, new_p );
return m_state.Move( m_syncer, old_p, new_p );
}
void Drive::Update()
{
Log( "Synchronizing files", log::info ) ;
m_state.Sync( m_syncer, m_options ) ;
UpdateChangeStamp( ) ;
}

View File

@ -53,7 +53,7 @@ private :
void FromRemote( const Entry& entry ) ;
void FromChange( const Entry& entry ) ;
void UpdateChangeStamp( ) ;
private :
Syncer *m_syncer ;
fs::path m_root ;

View File

@ -117,7 +117,7 @@ bool Entry::IsRemoved() const
std::string Entry::Name() const
{
return !m_title.empty() ? m_title : m_filename;
return !m_filename.empty() ? m_filename : m_title;
}
} // end of namespace gr

View File

@ -299,7 +299,7 @@ void State::Sync( Syncer *syncer, const Val& options )
// need to check if this introduces a new problem
DateTime last_change_time = m_last_change;
m_res.Root()->Sync( syncer, last_change_time, options ) ;
if ( last_change_time == m_last_change )
Trace( "nothing changed at the server side since %1%", m_last_change ) ;
else
@ -323,39 +323,39 @@ void State::ChangeStamp( long cstamp )
bool State::Move( Syncer* syncer, fs::path old_p, fs::path new_p )
{
if ( (fs::exists(new_p) && !fs::is_directory(new_p) ) || !fs::exists(old_p) )
return false;
if ( (fs::exists(new_p) && !fs::is_directory(new_p) ) || !fs::exists(old_p) )
return false;
//If path ends in a /, remove the /
if (new_p.string()[ new_p.string().size() - 1 ] == '/')
new_p = new_p.string().substr( 0, new_p.string().size() - 1 );
if (old_p.string()[ old_p.string().size() - 1 ] == '/')
old_p = old_p.string().substr( 0, old_p.string().size() - 1 );
//If path ends in a /, remove the /
if (new_p.string()[ new_p.string().size() - 1 ] == '/')
new_p = new_p.string().substr( 0, new_p.string().size() - 1 );
if (old_p.string()[ old_p.string().size() - 1 ] == '/')
old_p = old_p.string().substr( 0, old_p.string().size() - 1 );
//If new path is an existing directory, move the file into the directory
//instead of trying to rename it
if ( fs::is_directory(new_p) ){
new_p = new_p / old_p.filename();
}
Resource* res = m_res.Root();
Resource* newParentRes = m_res.Root();
for ( fs::path::iterator it = old_p.begin(); it != old_p.end(); ++it )
{
if ( *it != "." )
res = res->FindChild(it->string());
}
for ( fs::path::iterator it = new_p.begin(); it != new_p.end(); ++it )
{
if ( *it != "." && *it != new_p.filename() )
newParentRes = newParentRes->FindChild(it->string());
//If new path is an existing directory, move the file into the directory
//instead of trying to rename it
if ( fs::is_directory(new_p) ){
new_p = new_p / old_p.filename();
}
if ( res == 0 || newParentRes == 0 )
return false;
fs::rename(old_p, new_p); //Moves local file
syncer->Move(res, newParentRes, new_p.filename().string()); //Moves server file
return true;
Resource* res = m_res.Root();
Resource* newParentRes = m_res.Root();
for ( fs::path::iterator it = old_p.begin(); it != old_p.end(); ++it )
{
if ( *it != "." )
res = res->FindChild(it->string());
}
for ( fs::path::iterator it = new_p.begin(); it != new_p.end(); ++it )
{
if ( *it != "." && *it != new_p.filename() )
newParentRes = newParentRes->FindChild(it->string());
}
if ( res == 0 || newParentRes == 0 )
return false;
fs::rename(old_p, new_p); //Moves local file
syncer->Move(res, newParentRes, new_p.filename().string()); //Moves server file
return true;
}
} // end of namespace gr

View File

@ -80,7 +80,7 @@ private :
int m_cstamp ;
std::string m_dir ;
boost::regex m_ign ;
std::vector<Entry> m_unresolved ;
} ;

View File

@ -85,17 +85,17 @@ bool Syncer2::Create( Resource *res )
Log( "Cannot upload %1%: parent directory read-only. %2%", res->Name(), res->StateStr(), log::warning ) ;
return false ;
}
return Upload( res );
}
bool Syncer2::Move( Resource* res, Resource* newParentRes, std::string newFilename )
{
if ( res->ResourceID().empty() )
{
Log("Can't rename file %1%, no server id found", res->Name());
return false;
}
if ( res->ResourceID().empty() )
{
Log("Can't rename file %1%, no server id found", res->Name());
return false;
}
Val meta;
meta.Add( "title", Val(newFilename) );
@ -109,25 +109,25 @@ bool Syncer2::Move( Resource* res, Resource* newParentRes, std::string newFilena
// Issue metadata update request
{
std::string addRemoveParents("");
if (res->Parent()->IsRoot() )
addRemoveParents += "&removeParents=root";
else
addRemoveParents += "&removeParents=" + res->Parent()->ResourceID();
if ( newParentRes->IsRoot() )
addRemoveParents += "&addParents=root";
else
addRemoveParents += "&addParents=" + newParentRes->ResourceID();
std::string addRemoveParents("");
if (res->Parent()->IsRoot() )
addRemoveParents += "&removeParents=root";
else
addRemoveParents += "&removeParents=" + res->Parent()->ResourceID();
if ( newParentRes->IsRoot() )
addRemoveParents += "&addParents=root";
else
addRemoveParents += "&addParents=" + newParentRes->ResourceID();
http::Header hdr2 ;
hdr2.Add( "Content-Type: application/json" );
http::ValResponse vrsp ;
long http_code = 0;
//Don't change modified date because we're only moving
//Don't change modified date because we're only moving
http_code = m_http->Put( feeds::files + "/" + res->ResourceID() + "?modifiedDateBehavior=noChange" + addRemoveParents, json_meta, &vrsp, hdr2 ) ;
valr = vrsp.Response();
assert( !( valr["id"].Str().empty() ) );
}
return true;
return true;
}
std::string to_string( uint64_t n )

View File

@ -255,7 +255,7 @@ namespace std
{
v1.Swap( v2 ) ;
}
ostream& operator<<( ostream& os, gr::Val::TypeEnum t )
{
return os << static_cast<int>(t) ;

View File

@ -124,7 +124,7 @@ private :
template <typename T>
struct Impl ;
std::auto_ptr<Base> m_base ;
private :

View File

@ -93,7 +93,7 @@ Val Config::GetAll() const
for ( Val::Object::iterator i = cmd_obj.begin() ; i != cmd_obj.end() ; ++i )
obj[i->first] = i->second ;
return Val( obj ) ;
}