Call FC wrappers of copy and remove in rename()

to get around boost 1.67 boost::filesystem::copy() null pointer dereferencing issue
This commit is contained in:
abitmore 2018-08-09 12:57:08 -04:00
parent ce7cb0dd06
commit 35cb63d3ea

View file

@ -303,13 +303,14 @@ namespace fc {
void rename( const path& f, const path& t ) { void rename( const path& f, const path& t ) {
try { try {
boost::filesystem::rename( boost::filesystem::path(f), boost::filesystem::path(t) ); boost::filesystem::rename( boost::filesystem::path(f), boost::filesystem::path(t) );
} catch ( boost::system::system_error& ) { } catch ( boost::system::system_error& er ) {
try{ try {
boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) ); copy( f, t );
boost::filesystem::remove( boost::filesystem::path(f)); remove( f );
} catch ( boost::system::system_error& e ) { } catch ( fc::exception& e ) {
FC_THROW( "Rename from ${srcfile} to ${dstfile} failed because ${reason}", FC_RETHROW_EXCEPTION( e, error,
("srcfile",f)("dstfile",t)("reason",e.what() ) ); "Rename from ${srcfile} to ${dstfile} failed due to ${reason}, trying to copy then remove",
("srcfile",f)("dstfile",t)("reason",er.what()) );
} }
} catch ( ... ) { } catch ( ... ) {
FC_THROW( "Rename from ${srcfile} to ${dstfile} failed", FC_THROW( "Rename from ${srcfile} to ${dstfile} failed",