remove database auto purge methods

This commit is contained in:
Gnat008 2016-06-16 12:52:42 -04:00
parent fde634e054
commit fb8baeafd2
5 changed files with 0 additions and 98 deletions

View File

@ -138,16 +138,6 @@ public class CacheDataSource implements DataSource {
return result;
}
@Override
public Set<String> autoPurgeDatabase(long until) {
Set<String> cleared = source.autoPurgeDatabase(until);
for (String name : cleared) {
cachedAuths.invalidate(name);
}
return cleared;
}
@Override
public Set<String> getRecordsToPurge(long until) {
return source.getRecordsToPurge(until);

View File

@ -69,15 +69,6 @@ public interface DataSource extends Reloadable {
*/
boolean updatePassword(String user, HashedPassword password);
/**
* Purge all records in the database whose last login was longer ago than
* the given time if they do not have the bypass permission.
*
* @param until The minimum last login
* @return The account names that have been removed
*/
Set<String> autoPurgeDatabase(long until);
/**
* Get all records in the database whose last login was before the given time.
*

View File

@ -229,40 +229,6 @@ public class FlatFile implements DataSource {
return true;
}
@Override
public Set<String> autoPurgeDatabase(long until) {
BufferedReader br = null;
BufferedWriter bw = null;
ArrayList<String> lines = new ArrayList<>();
Set<String> cleared = new HashSet<>();
try {
br = new BufferedReader(new FileReader(source));
String line;
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args.length >= 4) {
if (Long.parseLong(args[3]) >= until) {
lines.add(line);
continue;
}
}
cleared.add(args[0]);
}
bw = new BufferedWriter(new FileWriter(source));
for (String l : lines) {
bw.write(l + "\n");
}
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return cleared;
} finally {
silentClose(br);
silentClose(bw);
}
return cleared;
}
@Override
public Set<String> getRecordsToPurge(long until) {
BufferedReader br = null;

View File

@ -612,29 +612,6 @@ public class MySQL implements DataSource {
return false;
}
@Override
public Set<String> autoPurgeDatabase(long until) {
Set<String> list = new HashSet<>();
String select = "SELECT " + col.NAME + " FROM " + tableName + " WHERE " + col.LAST_LOGIN + "<?;";
String delete = "DELETE FROM " + tableName + " WHERE " + col.LAST_LOGIN + "<?;";
try (Connection con = getConnection();
PreparedStatement selectPst = con.prepareStatement(select);
PreparedStatement deletePst = con.prepareStatement(delete)) {
selectPst.setLong(1, until);
try (ResultSet rs = selectPst.executeQuery()) {
while (rs.next()) {
list.add(rs.getString(col.NAME));
}
}
deletePst.setLong(1, until);
deletePst.executeUpdate();
} catch (SQLException ex) {
logSqlException(ex);
}
return list;
}
@Override
public Set<String> getRecordsToPurge(long until) {
Set<String> list = new HashSet<>();

View File

@ -292,28 +292,6 @@ public class SQLite implements DataSource {
return false;
}
@Override
public Set<String> autoPurgeDatabase(long until) {
Set<String> list = new HashSet<>();
String select = "SELECT " + col.NAME + " FROM " + tableName + " WHERE " + col.LAST_LOGIN + "<?;";
String delete = "DELETE FROM " + tableName + " WHERE " + col.LAST_LOGIN + "<?;";
try (PreparedStatement selectPst = con.prepareStatement(select);
PreparedStatement deletePst = con.prepareStatement(delete)) {
selectPst.setLong(1, until);
try (ResultSet rs = selectPst.executeQuery()) {
while (rs.next()) {
list.add(rs.getString(col.NAME));
}
}
deletePst.setLong(1, until);
deletePst.executeUpdate();
} catch (SQLException ex) {
logSqlException(ex);
}
return list;
}
@Override
public Set<String> getRecordsToPurge(long until) {
Set<String> list = new HashSet<>();