throw( e );
}
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "Failed to open '" + file.toString() + "', retrying", e));
Thread.sleep(500);
}
}
BDecoder decoder = new BDecoder();
if ( recovery_mode ){
decoder.setRecoveryMode( true );
}
Map res = decoder.decodeStream(bin, !skip_key_intern);
if ( using_backup && !recovery_mode ){
Debug.out( "Load of '" + original_file_name + "' had to revert to backup file" );
}
return( res );
}catch( Throwable e ){
Debug.printStackTrace( e );
try {
if (bin != null){
bin.close();
bin = null;
}
} catch (Exception x) {
Debug.printStackTrace( x );
}
// if we're not recovering then backup the file
if ( !recovery_mode ){
// Occurs when file is there but b0rked
// copy it in case it actually contains useful data, so it won't be overwritten next save
File bad;
int bad_id = 0;
while(true){
File test = new File( parent_dir, file.getName() + ".bad" + (bad_id==0?"":(""+bad_id)));
if ( !test.exists()){
bad = test;
break;
}
bad_id++;
}
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, LogEvent.LT_WARNING, "Read of '"
+ original_file_name + "' failed, decoding error. " + "Renaming to "
+ bad.getName()));
// copy it so its left in place for possible recovery