* Profiles: Skip and delete a corrupt profile read from disk

This commit is contained in:
zzz
2011-06-10 22:03:34 +00:00
parent c8afe4bcaf
commit 50578b34d0
3 changed files with 31 additions and 7 deletions

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 22;
public final static long BUILD = 23;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -269,8 +269,9 @@ class ProfilePersistenceHelper {
_log.debug("Loaded the profile for " + peer.toBase64() + " from " + file.getName());
return profile;
} catch (IllegalArgumentException iae) {
_log.error("Error loading profile from " +file.getName(), iae);
} catch (Exception e) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error loading properties from " + file.getAbsolutePath(), e);
file.delete();
return null;
}
@ -300,7 +301,7 @@ class ProfilePersistenceHelper {
return 0.0;
}
private void loadProps(Properties props, File file) {
private void loadProps(Properties props, File file) throws IOException {
InputStream fin = null;
try {
fin = new BufferedInputStream(new FileInputStream(file), 1);
@ -318,9 +319,6 @@ class ProfilePersistenceHelper {
_log.info("Loading compressed profile data from " + file.getName());
DataHelper.loadProps(props, new GZIPInputStream(fin));
}
} catch (IOException ioe) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error loading properties from " + file.getName(), ioe);
} finally {
try {
if (fin != null) fin.close();