Author: jflesch
Date: 2007-01-27 19:34:21 +0000 (Sat, 27 Jan 2007)
New Revision: 11630
Modified:
trunk/apps/Thaw/src/thaw/core/Core.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
trunk/apps/Thaw/src/thaw/plugins/index/Index.java
Log:
Set a maximum size when downloading index + clean the toolbar when we are
disconnected
Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java 2007-01-27 19:12:07 UTC (rev
11629)
+++ trunk/apps/Thaw/src/thaw/core/Core.java 2007-01-27 19:34:21 UTC (rev
11630)
@@ -370,6 +370,9 @@
if (mainWindow != null) {
mainWindow.setStatus(I18n.getMessage("thaw.statusBar.disconnected"),
java.awt.Color.RED);
+
+ /* not null because we want to force the cleaning */
+ mainWindow.changeButtonsInTheToolbar(this, new
java.util.Vector());
}
if (connection != null) {
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-01-27 19:12:07 UTC
(rev 11629)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-01-27 19:34:21 UTC
(rev 11630)
@@ -35,6 +35,7 @@
private int fromTheNodeProgress = 0;
private boolean progressReliable = false;
private long fileSize;
+ private long maxSize = 0;
private boolean running = false;
private boolean successful = true;
@@ -148,6 +149,21 @@
}
+
+ /**
+ * Another entry point allowing to specify a max size
+ */
+ public FCPClientGet(final String key, final int priority,
+ final int persistence, boolean globalQueue,
+ final int maxRetries,
+ String destinationDir,
+ long maxSize) {
+ this(key, priority, persistence, globalQueue, maxRetries,
+ destinationDir);
+ this.maxSize = maxSize;
+ }
+
+
public boolean start(final FCPQueueManager queueManager) {
attempt++;
running = true;
@@ -180,6 +196,9 @@
queryMessage.setValue("MaxRetries",
Integer.toString(maxRetries));
queryMessage.setValue("PriorityClass",
Integer.toString(priority));
+ if (maxSize > 0)
+ queryMessage.setValue("MaxSize",
Long.toString(maxSize));
+
if(destinationDir != null)
queryMessage.setValue("ClientToken", destinationDir);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-01-27 19:12:07 UTC
(rev 11629)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-01-27 19:34:21 UTC
(rev 11630)
@@ -50,7 +50,9 @@
public class Index extends Observable implements MutableTreeNode,
FileAndLinkList, IndexTreeNode, Observer {
+ private final static long MAX_SIZE = 5242880; /* 5MB */
+
private final Hsqldb db;
private int id;
private TreeNode parentNode;
@@ -691,7 +693,8 @@
clientGet = new FCPClientGet(key, 2, 2, false, -1,
-
System.getProperty("java.io.tmpdir"));
+
System.getProperty("java.io.tmpdir"),
+ MAX_SIZE);
/*
* These requests are usually quite fast, and don't consume too
much