From e3d6e96c5ced77d88641e8b736df57d43b08f7ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 11 Apr 2013 07:32:28 +0200 Subject: [PATCH] Add fields for temporary and final download directories. --- src/main/java/net/pterodactylus/xdcc/core/Core.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/xdcc/core/Core.java b/src/main/java/net/pterodactylus/xdcc/core/Core.java index 36768a4..4596f0d 100644 --- a/src/main/java/net/pterodactylus/xdcc/core/Core.java +++ b/src/main/java/net/pterodactylus/xdcc/core/Core.java @@ -72,6 +72,12 @@ public class Core extends AbstractIdleService { /** 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 channels = Sets.newHashSet(); @@ -95,10 +101,16 @@ public class Core extends AbstractIdleService { * * @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; } // @@ -327,7 +339,8 @@ public class Core extends AbstractIdleService { 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(); -- 2.7.4