Author: toad
Date: 2007-08-10 22:09:04 +0000 (Fri, 10 Aug 2007)
New Revision: 14584
Modified:
trunk/freenet/src/freenet/support/io/TempBucketFactory.java
trunk/freenet/src/freenet/support/io/TempFileBucket.java
Log:
Delete dead code
Modified: trunk/freenet/src/freenet/support/io/TempBucketFactory.java
===================================================================
--- trunk/freenet/src/freenet/support/io/TempBucketFactory.java 2007-08-10
22:08:15 UTC (rev 14583)
+++ trunk/freenet/src/freenet/support/io/TempBucketFactory.java 2007-08-10
22:09:04 UTC (rev 14584)
@@ -2,7 +2,6 @@
import java.io.IOException;
-import freenet.support.Logger;
import freenet.support.api.Bucket;
import freenet.support.api.BucketFactory;
@@ -19,8 +18,6 @@
*/
public class TempBucketFactory implements BucketFactory {
- private static boolean logDebug=true;
-
private final FilenameGenerator filenameGenerator;
public static long defaultIncrement = 4096;
@@ -29,7 +26,6 @@
// Storage accounting disabled by default.
public TempBucketFactory(FilenameGenerator filenameGenerator) {
- logDebug = Logger.shouldLog(Logger.DEBUG,this);
this.filenameGenerator = filenameGenerator;
}
@@ -55,33 +51,9 @@
*/
public TempFileBucket makeBucket(long size, float factor, long
increment)
throws IOException {
- logDebug = Logger.shouldLog(Logger.DEBUG,this);
long id = filenameGenerator.makeRandomFilename();
return new TempFileBucket(id, filenameGenerator);
}
- /**
- * Free bucket
- *
- * @param b
- * Description of the Parameter
- */
- public void freeBucket(Bucket b) {
- if (b instanceof TempFileBucket) {
- if (logDebug)
- Logger.debug(
- this,
- "Temp bucket released: "
- + ((TempFileBucket)
b).getFile().getAbsolutePath(),
- new Exception("debug"));
- if (!((TempFileBucket) b).release()) {
- System.err.println("Could not release temp
bucket" + b);
- Logger.error(
- this,
- "Could not release temp bucket " + b,
- new Exception("Failed to release
tempbucket"));
- }
- }
- }
}
Modified: trunk/freenet/src/freenet/support/io/TempFileBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/io/TempFileBucket.java 2007-08-10
22:08:15 UTC (rev 14583)
+++ trunk/freenet/src/freenet/support/io/TempFileBucket.java 2007-08-10
22:09:04 UTC (rev 14584)
@@ -1,10 +1,6 @@
package freenet.support.io;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Vector;
import freenet.support.Logger;
import freenet.support.SimpleFieldSet;
@@ -56,146 +52,6 @@
return true;
}
- /**
- * Release
- *
- * @return Success
- */
- public synchronized boolean release() {
- File file = getFile();
- if(Logger.shouldLog(Logger.MINOR, this))
- Logger.minor(this, "Releasing bucket: "+file, new
Exception("debug"));
- //System.err.println("FProxyServlet.TempFileBucket -- release:
" + // file.getAbsolutePath());
-
- //System.err.println("CALL STACK: ");
- //(new Exception()).printStackTrace();
-
- // Force all open streams closed.
- // Windows won't let us delete the file unless we
- // do this.
- logDebug = Logger.shouldLog(Logger.DEBUG, this);
- if (logDebug)
- Logger.debug(this, "Releasing TempFileBucket " + file);
- closing = true;
- for (int i = 0; i < streams.size(); i++) {
- try {
- if (streams.elementAt(i) instanceof
InputStream) {
- InputStream is = (InputStream)
streams.elementAt(i);
- is.close();
-
- if (logDebug) {
- Logger.debug(
- this,
- "closed open
InputStream !: "
- +
file.getAbsolutePath(),
- new Exception("debug"));
- if (is instanceof
FileBucketInputStream) {
- Logger.debug(
- this,
- "Open
InputStream created: ",
-
((FileBucketInputStream) is).e);
- }
- }
- } else if (streams.elementAt(i) instanceof
OutputStream) {
- OutputStream os = (OutputStream)
(streams.elementAt(i));
- os.close();
- if (logDebug) {
- Logger.debug(
- this,
- "closed open
OutputStream !: "
- +
file.getAbsolutePath(),
- new Exception("debug"));
-// if (os instanceof
FileBucketOutputStream) {
-// Logger.debug(
-// this,
-// "Open
OutputStream created: ",
-//
((FileBucketOutputStream) os).e);
-// }
-
- }
- }
- } catch (IOException ioe) {
- }
- }
- if (logDebug)
- Logger.debug(this, "Closed streams for " + file);
- if (released) {
- if(Logger.shouldLog(Logger.MINOR, this))
- Logger.minor(this,
- "Already released file: " +
file.getName());
- if (file.exists())
- throw new IllegalStateException(
- "already released file "
- + file.getName()
- + " BUT IT STILL EXISTS!");
- return true;
- }
- if (logDebug)
- Logger.debug(
- this,
- "Checked for released for " + file);
- released = true;
- if (file.exists()) {
- if (logDebug)
- Logger.debug(
- this,
- "Deleting bucket " + file.getName());
- if (!file.delete()) {
- Logger.error(
- this,
- "Delete failed on bucket " +
file.getName() + "which existed" + (file.exists() ? " and still exists" : " but
doesn't now"),
- new Exception());
- // Nonrecoverable; even though the user can't
fix it it's still very serious
- return false;
- }
- }
- if (logDebug)
- Logger.debug(
- this,
- "release() returning true for " + file);
- return true;
- }
-
- /**
- * Gets the released attribute of the TempFileBucket object
- *
- * @return The released value
- */
- public final synchronized boolean isReleased() {
- return released;
- }
-
-// /**
-// * Finalize
-// *
-// * @exception Throwable Description of the Exception
-// */
-// public void finalize() throws Throwable {
-// if (logDebug)
-// Logger.debug(this, "Finalizing TempFileBucket for " +
file);
-// super.finalize();
-// }
-
- protected Vector streams = new Vector(0, 1); // TFB is a very common
object, we need the space
- private boolean released;
- private boolean closing;
-
- protected synchronized void resetLength() {
- if (logDebug)
- Logger.debug(this, "Resetting length for " + getFile());
- }
-
- protected final synchronized void getLengthSynchronized(long len)
throws IOException {
- // Core.logger.log(this, "getLengthSynchronized("+len+
- // "); fakeLength = "+fakeLength,
Logger.DEBUG);
- if(len <= 0) return;
- length += len;
- }
-
- public synchronized String toString(){
- return "TempFileBucket (File:
'"+getFile().getAbsolutePath()+"', streams: "+streams.size();
- }
-
public SimpleFieldSet toFieldSet() {
if(deleteOnFinalize())
return null; // Not persistent