/** The event bus. */
private final EventBus eventBus;
+ /** The temporary directory to download files to. */
+ private final String temporaryDirectory;
+
+ /** The directory to move finished downloads to. */
+ private final String finalDirectory;
+
/** The channels that should be monitored. */
private final Collection<Channel> channels = Sets.newHashSet();
*
* @param eventBus
* The event bus
+ * @param temporaryDirectory
+ * The directory to download files to
+ * @param finalDirectory
+ * The directory to move finished files to
*/
@Inject
- public Core(EventBus eventBus) {
+ public Core(EventBus eventBus, String temporaryDirectory, String finalDirectory) {
this.eventBus = eventBus;
+ this.temporaryDirectory = temporaryDirectory;
+ this.finalDirectory = finalDirectory;
}
//
public void dccSendReceived(DccSendReceived dccSendReceived) {
logger.info(String.format("Starting download of %s.", dccSendReceived.filename()));
try {
- OutputStream fileOutputStream = new FileOutputStream(new File("/home/bombe/Temp", dccSendReceived.filename()));
+ File outputFile = new File(temporaryDirectory, dccSendReceived.filename());
+ OutputStream fileOutputStream = new FileOutputStream(outputFile);
DccReceiver dccReceiver = new DccReceiver(eventBus, dccSendReceived.inetAddress(), dccSendReceived.port(), dccSendReceived.filename(), dccSendReceived.filesize(), fileOutputStream);
dccReceivers.add(dccReceiver);
dccReceiver.start();