Add fields for temporary and final download directories.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 11 Apr 2013 05:32:28 +0000 (07:32 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 11 Apr 2013 05:32:28 +0000 (07:32 +0200)
src/main/java/net/pterodactylus/xdcc/core/Core.java

index 36768a4..4596f0d 100644 (file)
@@ -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<Channel> 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();