summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/TweetShell.java16
-rw-r--r--src/utils/Configuration.java2
2 files changed, 15 insertions, 3 deletions
diff --git a/src/main/TweetShell.java b/src/main/TweetShell.java
index fae4125..cb31511 100644
--- a/src/main/TweetShell.java
+++ b/src/main/TweetShell.java
@@ -37,6 +37,12 @@ public class TweetShell implements TwitterApi.PinSupplier {
private Stream stream_cached;
private final CompositeResultListener resultListeners;
+ /**
+ * Whether to convert uncompressed tweet files (e.g. "tweets.txt") to the
+ * compressed files ("tweets.txt.gz").
+ */
+ public final static String CFG_CONVERT_UNCOMPRESSED = "convert-uncompressed";
+
public TweetShell() {
resultListeners = new CompositeResultListener();
// by default, store something that counts responses
@@ -420,13 +426,19 @@ public class TweetShell implements TwitterApi.PinSupplier {
if (DataWriter.class.isAssignableFrom(rlCls)) {
Configuration config = Configuration.getConfig();
+ if (resultListeners.findListener(CompressableDataWriter.class) != null
+ || resultListeners.findListener(DataWriter.class) != null) {
+ System.err.println("Cannot enable both file and cfile.");
+ return false;
+ }
+
String tweetsFilename = config.getProperty(DataWriter.CFG_TWEETS_FILENAME);
try {
DataWriter dw;
if (CompressableDataWriter.class.isAssignableFrom(rlCls)) {
// compressed stream, convert by default (removing orig)
boolean convertUncompressed = Boolean.parseBoolean(
- config.getProperty("convert-uncompressed", "true"));
+ config.getProperty(CFG_CONVERT_UNCOMPRESSED, "true"));
dw = new CompressableDataWriter(
tweetsFilename, convertUncompressed);
} else {
@@ -434,8 +446,6 @@ public class TweetShell implements TwitterApi.PinSupplier {
}
dw.open();
resultListeners.register(dw);
- // save the changes to the config.
- config.save();
} catch (IOException ex) {
System.err.println("Could not open file for storing tweets:");
System.err.println(ex.getMessage());
diff --git a/src/utils/Configuration.java b/src/utils/Configuration.java
index f737706..f5122a5 100644
--- a/src/utils/Configuration.java
+++ b/src/utils/Configuration.java
@@ -9,6 +9,7 @@ import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
+import main.TweetShell;
/**
* Global configuration including user-specific settings.
@@ -50,6 +51,7 @@ public class Configuration {
// set default preferences as needed
defs.setProperty(DataWriter.CFG_TWEETS_FILENAME, "tweets.txt");
+ defs.setProperty(TweetShell.CFG_CONVERT_UNCOMPRESSED, "true");
return defs;
}