mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Check for symlinks when deleting directories. Allow Database.open()
and close() to throw IOExceptions as well as DatabaseExceptions.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user