From: Mailing l. f. S. c. m. <jtc...@li...> - 2007-06-30 19:44:57
|
Revision: 2668 http://jtcfrost.svn.sourceforge.net/jtcfrost/?rev=2668&view=rev Author: bback Date: 2007-06-30 12:44:54 -0700 (Sat, 30 Jun 2007) Log Message: ----------- 0.7: the target filename of a PUT is now set when you add a file manually to the uploads. This prevents problems when downloading the file with applications that have no special circumvention handling like Frost. ("fcp2.setTargetfilenameForManualPut" in frost.ini) Modified Paths: -------------- trunk/frost-wot/source/frost/SettingsClass.java trunk/frost-wot/source/frost/fcp/fcp07/FcpPersistentConnectionTools.java trunk/frost-wot/source/frost/fileTransfer/PersistenceManager.java Modified: trunk/frost-wot/source/frost/SettingsClass.java =================================================================== --- trunk/frost-wot/source/frost/SettingsClass.java 2007-06-30 17:49:42 UTC (rev 2667) +++ trunk/frost-wot/source/frost/SettingsClass.java 2007-06-30 19:44:54 UTC (rev 2668) @@ -73,6 +73,7 @@ public static final String FCP2_DEFAULT_PRIO_MESSAGE = "fcp2.defaultPriorityMessage"; // not in gui dialog! public static final String FCP2_DEFAULT_PRIO_FILE = "fcp2.defaultPriorityFile"; // not in gui dialog! + public static final String FCP2_SET_TARGETFILENAME_FOR_MANUAL_PUT = "fcp2.setTargetfilenameForManualPut"; // not in gui dialog! public static final String AUTO_SAVE_INTERVAL = "autoSaveInterval"; public static final String DISABLE_FILESHARING = "disableFilesharing"; @@ -749,6 +750,7 @@ defaults.put(FCP2_DEFAULT_PRIO_MESSAGE, "2"); defaults.put(FCP2_DEFAULT_PRIO_FILE, "3"); + defaults.put(FCP2_SET_TARGETFILENAME_FOR_MANUAL_PUT, "true"); defaults.put(ALTERNATE_EDITOR_COMMAND, fn + "path" + fs + "to" + fs + "editor" + " %f"); defaults.put(BOARD_AUTOUPDATE_ENABLED, "true"); Modified: trunk/frost-wot/source/frost/fcp/fcp07/FcpPersistentConnectionTools.java =================================================================== --- trunk/frost-wot/source/frost/fcp/fcp07/FcpPersistentConnectionTools.java 2007-06-30 17:49:42 UTC (rev 2667) +++ trunk/frost-wot/source/frost/fcp/fcp07/FcpPersistentConnectionTools.java 2007-06-30 19:44:54 UTC (rev 2668) @@ -70,10 +70,14 @@ /** * Starts a persistent put. */ - public void startPersistentPut(final String id, final File sourceFile, final boolean doMime) { - + public void startPersistentPut( + final String id, + final File sourceFile, + final boolean doMime, + final boolean setTargetFileName) + { // else start a new request with DDA - final List<String> msg = getDefaultPutMessage(id, sourceFile, doMime); + final List<String> msg = getDefaultPutMessage(id, sourceFile, doMime, setTargetFileName); msg.add("UploadFrom=disk"); msg.add("Filename=" + sourceFile.getAbsolutePath()); @@ -129,7 +133,12 @@ /** * Returns the common part of a put request, used for a put with type DIRECT and DISK together. */ - private List<String> getDefaultPutMessage(final String id, final File sourceFile, final boolean doMime) { + private List<String> getDefaultPutMessage( + final String id, + final File sourceFile, + final boolean doMime, + final boolean setTargetFileName) + { final LinkedList<String> lst = new LinkedList<String>(); lst.add("ClientPut"); lst.add("URI=CHK@"); @@ -137,7 +146,11 @@ lst.add("Verbosity=-1"); lst.add("MaxRetries=-1"); lst.add("DontCompress=false"); // force compression - lst.add("TargetFilename="); + if( setTargetFileName ) { + lst.add("TargetFilename="+sourceFile.getName()); // prevents problems downloading this file with other apps + } else { + lst.add("TargetFilename="); // default for shared files: we always want the same key for the same content! + } if (doMime) { lst.add("Metadata.ContentType=" + DefaultMIMETypes.guessMIMEType(sourceFile.getAbsolutePath())); } else { @@ -155,8 +168,13 @@ * Returns the first NodeMessage sent by the node after the transfer (PersistentPut or any error message). * After this method was called this connection is unuseable. */ - public NodeMessage startDirectPersistentPut(final String id, final File sourceFile, final boolean doMime) throws IOException { - + public NodeMessage startDirectPersistentPut( + final String id, + final File sourceFile, + final boolean doMime, + final boolean setTargetFileName) + throws IOException + { final FcpSocket newSocket = FcpSocket.create(FcpPersistentConnection.getInstance().getNodeAddress()); if( newSocket == null ) { return null; @@ -164,7 +182,7 @@ final BufferedOutputStream dataOutput = new BufferedOutputStream(newSocket.getFcpSock().getOutputStream()); - final List<String> msg = getDefaultPutMessage(id, sourceFile, doMime); + final List<String> msg = getDefaultPutMessage(id, sourceFile, doMime, setTargetFileName); msg.add("UploadFrom=direct"); msg.add("DataLength=" + Long.toString(sourceFile.length())); msg.add("Data"); Modified: trunk/frost-wot/source/frost/fileTransfer/PersistenceManager.java =================================================================== --- trunk/frost-wot/source/frost/fileTransfer/PersistenceManager.java 2007-06-30 17:49:42 UTC (rev 2667) +++ trunk/frost-wot/source/frost/fileTransfer/PersistenceManager.java 2007-06-30 19:44:54 UTC (rev 2668) @@ -450,15 +450,19 @@ // start the upload if( isDDA() ) { final boolean doMime; + final boolean setTargetFileName; if( ulItem.isSharedFile() ) { doMime = false; + setTargetFileName = false; } else { doMime = true; + setTargetFileName = true; } fcpTools.startPersistentPut( ulItem.getGqIdentifier(), ulItem.getFile(), - doMime); + doMime, + setTargetFileName); } else { // if UploadManager selected this file then it is not already in progress! directTransferQueue.appendItemToQueue(ulItem); @@ -601,7 +605,7 @@ public void run() { final int maxAllowedExceptions = 5; - int occuredExceptions = 0; + int catchedExceptions = 0; while(true) { try { @@ -621,12 +625,15 @@ final String gqid = ulItem.getGqIdentifier(); final File sourceFile = ulItem.getFile(); final boolean doMime; + final boolean setTargetFileName; if( ulItem.isSharedFile() ) { doMime = false; + setTargetFileName = false; } else { doMime = true; + setTargetFileName = true; } - final NodeMessage answer = fcpTools.startDirectPersistentPut(gqid, sourceFile, doMime); + final NodeMessage answer = fcpTools.startDirectPersistentPut(gqid, sourceFile, doMime, setTargetFileName); if( answer == null ) { final String desc = "Could not open a new FCP2 socket for direct put!"; final FcpResultPut result = new FcpResultPut(FcpResultPut.Error, -1, desc, false); @@ -662,10 +669,10 @@ } catch(Throwable t) { logger.log(Level.SEVERE, "Exception catched",t); - occuredExceptions++; + catchedExceptions++; } - if( occuredExceptions > maxAllowedExceptions ) { + if( catchedExceptions > maxAllowedExceptions ) { logger.log(Level.SEVERE, "Stopping DirectTransferThread because of too much exceptions"); break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |