mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-1217 boost rename doesn't work across partitions, so copy and then delete
This commit is contained in:
parent
ab204d9f24
commit
2353944ea0
@ -1616,6 +1616,16 @@ namespace mongo {
|
||||
|
||||
typedef boost::filesystem::path Path;
|
||||
|
||||
void boostRenameWrapper( const Path &from, const Path &to ) {
|
||||
try {
|
||||
boost::filesystem::rename( from, to );
|
||||
} catch ( const boost::filesystem::basic_filesystem_error< Path > & ) {
|
||||
// boost rename doesn't work across partitions
|
||||
boost::filesystem::copy_file( from, to);
|
||||
boost::filesystem::remove( from );
|
||||
}
|
||||
}
|
||||
|
||||
// back up original database files to 'temp' dir
|
||||
void _renameForBackup( const char *database, const Path &reservedPath ) {
|
||||
Path newPath( reservedPath );
|
||||
@ -1629,7 +1639,7 @@ namespace mongo {
|
||||
virtual bool apply( const Path &p ) {
|
||||
if ( !boost::filesystem::exists( p ) )
|
||||
return false;
|
||||
boost::filesystem::rename( p, newPath_ / ( p.leaf() + ".bak" ) );
|
||||
boostRenameWrapper( p, newPath_ / ( p.leaf() + ".bak" ) );
|
||||
return true;
|
||||
}
|
||||
virtual const char * op() const {
|
||||
@ -1652,7 +1662,7 @@ namespace mongo {
|
||||
virtual bool apply( const Path &p ) {
|
||||
if ( !boost::filesystem::exists( p ) )
|
||||
return false;
|
||||
boost::filesystem::rename( p, newPath_ / p.leaf() );
|
||||
boostRenameWrapper( p, newPath_ / p.leaf() );
|
||||
return true;
|
||||
}
|
||||
virtual const char * op() const {
|
||||
|
Loading…
Reference in New Issue
Block a user