mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-22 23:59:54 +01:00
Java 1.5 compatibility changes (for OSX 10.4). We depend on commons-io for a single method... might be worth copying the source into FileUtils if the license permits.
This commit is contained in:
@@ -15,5 +15,6 @@
|
|||||||
<classpathentry kind="lib" path="lib/test/hamcrest-core-1.1.jar"/>
|
<classpathentry kind="lib" path="lib/test/hamcrest-core-1.1.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/test/hamcrest-library-1.1.jar"/>
|
<classpathentry kind="lib" path="lib/test/hamcrest-library-1.1.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/test/jmock-2.5.1.jar"/>
|
<classpathentry kind="lib" path="lib/test/jmock-2.5.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-io-2.0.1.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.sf.briar.db;
|
package net.sf.briar.db;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -13,6 +14,8 @@ import net.sf.briar.api.crypto.Password;
|
|||||||
import net.sf.briar.api.db.DatabasePassword;
|
import net.sf.briar.api.db.DatabasePassword;
|
||||||
import net.sf.briar.api.db.DbException;
|
import net.sf.briar.api.db.DbException;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileSystemUtils;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
/** Contains all the H2-specific code for the database. */
|
/** Contains all the H2-specific code for the database. */
|
||||||
@@ -50,13 +53,17 @@ class H2Database extends JdbcDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getFreeSpace() throws DbException {
|
public long getFreeSpace() throws DbException {
|
||||||
File dir = home.getParentFile();
|
try {
|
||||||
long free = dir.getFreeSpace();
|
File dir = home.getParentFile();
|
||||||
long used = getDiskSpace(dir);
|
long free = FileSystemUtils.freeSpaceKb(dir.getAbsolutePath());
|
||||||
long quota = maxSize - used;
|
long used = getDiskSpace(dir);
|
||||||
long min = Math.min(free, quota);
|
long quota = maxSize - used;
|
||||||
if(LOG.isLoggable(Level.FINE)) LOG.fine("Free space: " + min);
|
long min = Math.min(free, quota);
|
||||||
return min;
|
if(LOG.isLoggable(Level.FINE)) LOG.fine("Free space: " + min);
|
||||||
|
return min;
|
||||||
|
} catch(IOException e) {
|
||||||
|
throw new DbException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -442,7 +442,8 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
ps.setBytes(4, m.getAuthor().getBytes());
|
ps.setBytes(4, m.getAuthor().getBytes());
|
||||||
ps.setLong(5, m.getTimestamp());
|
ps.setLong(5, m.getTimestamp());
|
||||||
ps.setInt(6, m.getSize());
|
ps.setInt(6, m.getSize());
|
||||||
ps.setBlob(7, new ByteArrayInputStream(m.getBytes()));
|
byte[] raw = m.getBytes();
|
||||||
|
ps.setBinaryStream(7, new ByteArrayInputStream(raw), raw.length);
|
||||||
ps.setInt(8, 0);
|
ps.setInt(8, 0);
|
||||||
int rowsAffected = ps.executeUpdate();
|
int rowsAffected = ps.executeUpdate();
|
||||||
assert rowsAffected == 1;
|
assert rowsAffected == 1;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class InvitationWorker implements Runnable {
|
|||||||
try {
|
try {
|
||||||
transports = databaseComponent.getTransports();
|
transports = databaseComponent.getTransports();
|
||||||
} catch(DbException e) {
|
} catch(DbException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e.getMessage());
|
||||||
}
|
}
|
||||||
FileOutputStream out = new FileOutputStream(invitationDat);
|
FileOutputStream out = new FileOutputStream(invitationDat);
|
||||||
Writer w = writerFactory.createWriter(out);
|
Writer w = writerFactory.createWriter(out);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SigningDigestingInputStream extends FilterInputStream {
|
|||||||
try {
|
try {
|
||||||
signature.update(b);
|
signature.update(b);
|
||||||
} catch(SignatureException e) {
|
} catch(SignatureException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(digesting) messageDigest.update(b);
|
if(digesting) messageDigest.update(b);
|
||||||
@@ -52,7 +52,7 @@ class SigningDigestingInputStream extends FilterInputStream {
|
|||||||
try {
|
try {
|
||||||
signature.update(b, off, len);
|
signature.update(b, off, len);
|
||||||
} catch(SignatureException e) {
|
} catch(SignatureException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(digesting) messageDigest.update(b, off, len);
|
if(digesting) messageDigest.update(b, off, len);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class SigningDigestingOutputStream extends FilterOutputStream {
|
|||||||
try {
|
try {
|
||||||
signature.update(b, off, len);
|
signature.update(b, off, len);
|
||||||
} catch(SignatureException e) {
|
} catch(SignatureException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(digesting) messageDigest.update(b, off, len);
|
if(digesting) messageDigest.update(b, off, len);
|
||||||
@@ -57,7 +57,7 @@ class SigningDigestingOutputStream extends FilterOutputStream {
|
|||||||
try {
|
try {
|
||||||
signature.update((byte) b);
|
signature.update((byte) b);
|
||||||
} catch(SignatureException e) {
|
} catch(SignatureException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(digesting) messageDigest.update((byte) b);
|
if(digesting) messageDigest.update((byte) b);
|
||||||
|
|||||||
Reference in New Issue
Block a user