summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-08-02 14:41:36 -0600
committerJared Adams <jaxad0127@gmail.com>2010-08-02 14:41:36 -0600
commite58fff5ae4adc9b113763b5ce7fa702222b68fd7 (patch)
treedaad40dc0dd254b02ca261dba3166f94ff4f97cd
parenta54895a2925c66a64b9abf5408133ea3099b8197 (diff)
downloadserverdata-e58fff5ae4adc9b113763b5ce7fa702222b68fd7.tar.gz
serverdata-e58fff5ae4adc9b113763b5ce7fa702222b68fd7.tar.bz2
serverdata-e58fff5ae4adc9b113763b5ce7fa702222b68fd7.tar.xz
serverdata-e58fff5ae4adc9b113763b5ce7fa702222b68fd7.zip
Fix how purger works
It now ignores accounts that haven't been used yet and outputs the removed account names (suitable for a public purge list).
-rw-r--r--tools/Purger.java48
1 files changed, 27 insertions, 21 deletions
diff --git a/tools/Purger.java b/tools/Purger.java
index 1bb6a1bd..115847e6 100644
--- a/tools/Purger.java
+++ b/tools/Purger.java
@@ -11,7 +11,7 @@ import java.util.*;
public static void main(String[] args) {
if (args.length != 2) {
- System.out.println(
+ System.err.println(
"Usage: java Purger <folder> <date>\n" +
" - folder: is the path to account.txt and athena.txt files.\n" +
" - date: accounts created before this date will be purged (dd/mm/yy or yyyy-mm-dd).");
@@ -26,11 +26,11 @@ import java.util.*;
File folder = new File(args[0]);
// Do some sanity checking
if (!folder.exists()) {
- System.out.println("Folder does not exist!");
+ System.err.println("Folder does not exist!");
return;
}
if (!folder.isDirectory()) {
- System.out.println("Folder is not a folder!");
+ System.err.println("Folder is not a folder!");
return;
}
@@ -52,9 +52,11 @@ import java.util.*;
}
if (purgeDate == null) {
- System.out.println("ERROR: Date format not recognized.");
+ System.err.println("ERROR: Date format not recognized.");
return;
}
+
+ System.out.printf("Removing accounts unused since %tF\n", purgeDate);
String line;
@@ -75,7 +77,9 @@ import java.util.*;
}
else {
// Server accounts should not be purged
- if (!fields[4].equals("S")) {
+ if (fields[4].equals("S")) {
+ copy = true;
+ } else {
accounts++;
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
@@ -84,21 +88,27 @@ import java.util.*;
activeAccounts.add(fields[0]);
copy = true;
}
+ else
+ {
+ System.out.println("Removing " + fields[1]);
+ }
}
catch (ParseException e) {
- System.out.println(
- "ERROR: Wrong date format in account.txt. ("
- + accounts + ": " + line + ")");
- //return;
+ // Ignore accounts that haven't been used yet
+ if (fields[3].equals("-")) {
+ activeAccounts.add(fields[0]);
+ copy = true;
+ }
+ else {
+ System.err.println("ERROR: Wrong date format in account.txt. (" + accounts + ": " + line + ")");
+ System.out.println("Removing " + fields[1]);
+ }
}
catch (Exception e) {
e.printStackTrace();
return;
}
}
- else {
- copy = true;
- }
}
if (copy) {
try {
@@ -113,19 +123,16 @@ import java.util.*;
output.close();
}
catch (FileNotFoundException e ) {
- System.out.println(
- "ERROR: file " + oldAccount.getAbsolutePath() + " not found.");
+ System.err.println("ERROR: file " + oldAccount.getAbsolutePath() + " not found.");
return;
}
catch (Exception e) {
- System.out.println("ERROR: unable to process account.txt");
+ System.err.println("ERROR: unable to process account.txt");
e.printStackTrace();
return;
}
- System.out.println(
- "Removed " + (accounts - activeAccounts.size()) + "/" +
- accounts + " accounts.");
+ System.out.println("Removed " + (accounts - activeAccounts.size()) + "/" + accounts + " accounts.");
// Remove characters
try {
@@ -161,12 +168,11 @@ import java.util.*;
output.close();
}
catch (FileNotFoundException e ) {
- System.out.println(
- "ERROR: file " + oldAthena.getAbsolutePath() + " not found.");
+ System.err.println("ERROR: file " + oldAthena.getAbsolutePath() + " not found.");
return;
}
catch (Exception e) {
- System.out.println("ERROR: unable to process athena.txt");
+ System.err.println("ERROR: unable to process athena.txt");
e.printStackTrace();
return;
}