Check for symlinks when deleting directories. Allow Database.open()

and close() to throw IOExceptions as well as DatabaseExceptions.
This commit is contained in:
akwizgran
2011-10-03 18:35:18 +01:00
parent 72b594d270
commit 74ca71d9c1
8 changed files with 87 additions and 80 deletions

View File

@@ -1,5 +1,6 @@
package net.sf.briar.db;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
@@ -48,13 +49,13 @@ interface Database<T> {
* @param resume True to reopen an existing database, false to create a
* new one.
*/
void open(boolean resume) throws DbException;
void open(boolean resume) throws DbException, IOException;
/**
* Prevents new transactions from starting, waits for all current
* transactions to finish, and closes the database.
*/
void close() throws DbException;
void close() throws DbException, IOException;
/** Starts a new transaction and returns an object representing it. */
T startTransaction() throws DbException;

View File

@@ -96,12 +96,12 @@ DatabaseCleaner.Callback {
this.cleaner = cleaner;
}
public void open(boolean resume) throws DbException {
public void open(boolean resume) throws DbException, IOException {
db.open(resume);
cleaner.startCleaning(this, MAX_MS_BETWEEN_SPACE_CHECKS);
}
public void close() throws DbException {
public void close() throws DbException, IOException {
cleaner.stopCleaning();
db.close();
}

View File

@@ -46,7 +46,7 @@ class H2Database extends JdbcDatabase {
this.maxSize = maxSize;
}
public void open(boolean resume) throws DbException {
public void open(boolean resume) throws DbException, IOException {
super.open(resume, home.getParentFile(), "org.h2.Driver");
}

View File

@@ -2,6 +2,7 @@ package net.sf.briar.db;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -242,7 +243,7 @@ abstract class JdbcDatabase implements Database<Connection> {
}
protected void open(boolean resume, File dir, String driverClass)
throws DbException {
throws DbException, IOException {
if(resume) {
if(!dir.exists()) throw new DbException();
if(!dir.isDirectory()) throw new DbException();