mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +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:
@@ -1,6 +1,7 @@
|
||||
package net.sf.briar.db;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
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.DbException;
|
||||
|
||||
import org.apache.commons.io.FileSystemUtils;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/** Contains all the H2-specific code for the database. */
|
||||
@@ -50,13 +53,17 @@ class H2Database extends JdbcDatabase {
|
||||
}
|
||||
|
||||
public long getFreeSpace() throws DbException {
|
||||
File dir = home.getParentFile();
|
||||
long free = dir.getFreeSpace();
|
||||
long used = getDiskSpace(dir);
|
||||
long quota = maxSize - used;
|
||||
long min = Math.min(free, quota);
|
||||
if(LOG.isLoggable(Level.FINE)) LOG.fine("Free space: " + min);
|
||||
return min;
|
||||
try {
|
||||
File dir = home.getParentFile();
|
||||
long free = FileSystemUtils.freeSpaceKb(dir.getAbsolutePath());
|
||||
long used = getDiskSpace(dir);
|
||||
long quota = maxSize - used;
|
||||
long min = Math.min(free, quota);
|
||||
if(LOG.isLoggable(Level.FINE)) LOG.fine("Free space: " + min);
|
||||
return min;
|
||||
} catch(IOException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user