Author: nextgens
Date: 2008-07-16 10:12:24 +0000 (Wed, 16 Jul 2008)
New Revision: 21142
Modified:
trunk/freenet/src/freenet/client/async/SingleFileInserter.java
trunk/freenet/src/freenet/l10n/L10n.java
trunk/freenet/src/freenet/support/io/BucketChainBucket.java
trunk/freenet/src/freenet/support/io/BucketChainBucketFactory.java
trunk/freenet/src/freenet/support/io/BucketTools.java
Log:
revert r21141 (commited too much)
Modified: trunk/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleFileInserter.java
2008-07-16 10:08:09 UTC (rev 21141)
+++ trunk/freenet/src/freenet/client/async/SingleFileInserter.java
2008-07-16 10:12:24 UTC (rev 21142)
@@ -14,7 +14,6 @@
import freenet.keys.BaseClientKey;
import freenet.keys.CHKBlock;
import freenet.keys.FreenetURI;
- import freenet.keys.NodeCHK;
import freenet.keys.SSKBlock;
import freenet.support.Logger;
import freenet.support.OOMHandler;
@@ -22,7 +21,6 @@
import freenet.support.api.Bucket;
import freenet.support.compress.CompressionOutputSizeException;
import freenet.support.compress.Compressor;
-import freenet.support.io.BucketChainBucketFactory;
import freenet.support.io.BucketTools;
/**
@@ -172,7 +170,7 @@
ctx.eventProducer.produceEvent(new StartedCompressionEvent(i));
Compressor comp =
Compressor.getCompressionAlgorithmByDifficulty(i);
Bucket result;
- result = comp.compress(origData, new
BucketChainBucketFactory(ctx.persistentBucketFactory, NodeCHK.BLOCK_SIZE),
origData.size());
+ result = comp.compress(origData,
ctx.persistentBucketFactory, origData.size());
if(result.size() <
oneBlockCompressedSize) {
bestCodec = comp;
if(bestCompressedData != null)
Modified: trunk/freenet/src/freenet/l10n/L10n.java
===================================================================
--- trunk/freenet/src/freenet/l10n/L10n.java 2008-07-16 10:08:09 UTC (rev
21141)
+++ trunk/freenet/src/freenet/l10n/L10n.java 2008-07-16 10:12:24 UTC (rev
21142)
@@ -94,7 +94,6 @@
* @throws MissingResourceException
*/
public static void setLanguage(String selectedLanguage) throws
MissingResourceException {
- selectedLanguage = mapLanguageNameToLongName(selectedLanguage);
synchronized (sync) {
Logger.normal(CLASS_NAME, "Changing the current
language to : " + selectedLanguage);
currentClass = new L10n(selectedLanguage);
@@ -370,24 +369,6 @@
return null;
}
- /**
- * Map a language identifier to its corresponding long name
- *
- * @param The name to look for
- * @return The full text language name OR null if not found
- */
- public static String mapLanguageNameToLongName(String name) {
- for(int i=0; i<AVAILABLE_LANGUAGES.length; i++) {
- String currentShortCode = AVAILABLE_LANGUAGES[i][0];
- String currentLongName = AVAILABLE_LANGUAGES[i][1];
- String currentCountryCodeName =
AVAILABLE_LANGUAGES[i][2];
-
- if(currentShortCode.equalsIgnoreCase(name) ||
currentLongName.equalsIgnoreCase(name) ||
currentCountryCodeName.equalsIgnoreCase(name))
- return currentLongName;
- }
- return null;
- }
-
public static boolean isOverridden(String key) {
synchronized(sync) {
if(translationOverride == null) return false;
Modified: trunk/freenet/src/freenet/support/io/BucketChainBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/io/BucketChainBucket.java 2008-07-16
10:08:09 UTC (rev 21141)
+++ trunk/freenet/src/freenet/support/io/BucketChainBucket.java 2008-07-16
10:12:24 UTC (rev 21142)
@@ -41,7 +41,7 @@
list[i].free();
}
}
-
+
/** Equivalent to free(), but don't free the underlying buckets. */
public void clear() {
synchronized(this) {
@@ -49,7 +49,7 @@
buckets.clear();
}
}
-
+
public synchronized Bucket[] getBuckets() {
return (Bucket[]) buckets.toArray(new Bucket[buckets.size()]);
}
Modified: trunk/freenet/src/freenet/support/io/BucketChainBucketFactory.java
===================================================================
--- trunk/freenet/src/freenet/support/io/BucketChainBucketFactory.java
2008-07-16 10:08:09 UTC (rev 21141)
+++ trunk/freenet/src/freenet/support/io/BucketChainBucketFactory.java
2008-07-16 10:12:24 UTC (rev 21142)
@@ -19,4 +19,4 @@
return new BucketChainBucket(blockSize, factory);
}
-}
\ No newline at end of file
+}
Modified: trunk/freenet/src/freenet/support/io/BucketTools.java
===================================================================
--- trunk/freenet/src/freenet/support/io/BucketTools.java 2008-07-16
10:08:09 UTC (rev 21141)
+++ trunk/freenet/src/freenet/support/io/BucketTools.java 2008-07-16
10:12:24 UTC (rev 21142)
@@ -334,24 +334,27 @@
* and the data written to them.
*
* Note that this method will allocate a buffer of size splitSize.
- * @param freeData
+ * @param freeData
* @throws IOException If there is an error creating buckets, reading
from
* the provided bucket, or writing to created buckets.
*/
public static Bucket[] split(Bucket origData, int splitSize,
BucketFactory bf, boolean freeData) throws IOException {
if(origData instanceof FileBucket) {
- if(freeData)
+ if(freeData) {
Logger.error(BucketTools.class, "Asked to free
data when splitting a FileBucket ?!?!? Not freeing as this would clobber the
split result...");
+ }
return ((FileBucket)origData).split(splitSize);
}
if(origData instanceof BucketChainBucket) {
- BucketChainBucket data = (BucketChainBucket) origData;
+ BucketChainBucket data = (BucketChainBucket)origData;
if(data.bucketSize == splitSize) {
+ Bucket[] buckets = data.getBuckets();
if(freeData)
data.clear();
- return data.getBuckets();
- } else
- Logger.error(BucketTools.class, "Incompatible
split size splitting a BucketChainBucket: his split size is " + data.bucketSize
+ " but mine is " + splitSize + " - we will copy the data, but this suggests a
bug", new Exception("debug"));
+ return buckets;
+ } else {
+ Logger.error(BucketTools.class, "Incompatible
split size splitting a BucketChainBucket: his split size is "+data.bucketSize+"
but mine is "+splitSize+" - we will copy the data, but this suggests a bug",
new Exception("debug"));
+ }
}
long length = origData.size();
if(length > ((long)Integer.MAX_VALUE) * splitSize)