Author: jflesch
Date: 2007-10-29 00:19:53 +0000 (Mon, 29 Oct 2007)
New Revision: 15630
Modified:
trunk/apps/Thaw/src/thaw/core/Config.java
trunk/apps/Thaw/src/thaw/plugins/index/CommentTab.java
trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
Log:
Argh, I'm stupid : I didn't close most of the file descriptor that I used
Modified: trunk/apps/Thaw/src/thaw/core/Config.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Config.java 2007-10-28 22:12:19 UTC (rev
15629)
+++ trunk/apps/Thaw/src/thaw/core/Config.java 2007-10-29 00:19:53 UTC (rev
15630)
@@ -334,6 +334,11 @@
return false;
}
+ try {
+ configOut.getWriter().close();
+ } catch(java.io.IOException e) {
+ Logger.warning(this, "Can't close cleanly the config
file");
+ }
return true;
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/CommentTab.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/CommentTab.java 2007-10-28
22:12:19 UTC (rev 15629)
+++ trunk/apps/Thaw/src/thaw/plugins/index/CommentTab.java 2007-10-29
00:19:53 UTC (rev 15630)
@@ -162,9 +162,7 @@
+" '"+index.toString()+"'"
+" :");
else
-
titleLabel.setText(I18n.getMessage("thaw.plugin.index.comment.commentListTitle")
- +" (null)"
- +" :");
+ hideTab();
}
for (Iterator it = buttonActions.iterator();
Modified: trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-10-28
22:12:19 UTC (rev 15629)
+++ trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-10-29
00:19:53 UTC (rev 15630)
@@ -502,6 +502,12 @@
return;
}
+ try {
+ outputStream.close();
+ } catch(IOException e) {
+ Logger.warning(new DatabaseManager(), "Can't close the
export file cleanly");
+ }
+
Logger.info(new DatabaseManager(), "Export done");
}
@@ -734,6 +740,11 @@
}
}
+ try {
+ input.close();
+ } catch(java.io.IOException e) {
+ Logger.warning(new DatabaseManager(), "Unable to close
cleanly the xml file");
+ }
indexBrowser.getIndexTree().getRoot().forceReload();
indexBrowser.getIndexTree().refresh();
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-10-28 22:12:19 UTC (rev 15629)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-10-29 00:19:53 UTC (rev 15630)
@@ -749,9 +749,6 @@
IndexFolder folder = ((IndexFolder)node);
- /**
- * to avoid the collision due to the vector in the
IndexFolder
- */
if (folder == null || "".equals(folder.toString())) {
return false;
}
@@ -1000,6 +997,12 @@
}
new IndexParser(((Index)getTarget())).generateXML(out);
+
+ try {
+ out.close();
+ } catch(java.io.IOException e) {
+ Logger.warning(this, "Can't close the export
file cleanly");
+ }
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java 2007-10-28
22:12:19 UTC (rev 15629)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java 2007-10-29
00:19:53 UTC (rev 15630)
@@ -60,10 +60,14 @@
public boolean generateXML(String path) {
try {
- generateXML(new FileOutputStream(new File(path)));
+ FileOutputStream stream = new FileOutputStream(new
File(path));
+ generateXML(stream);
+ stream.close();
return true;
} catch(java.io.FileNotFoundException e) {
Logger.error(this, "File not found exception ?!");
+ } catch(java.io.IOException e) {
+ Logger.error(this, "IOException while generating the
index: "+e.toString());
}
return false;
}
@@ -284,9 +288,13 @@
*/
public void loadXML(final String filePath, boolean clean) {
try {
- loadXML(new FileInputStream(filePath), clean);
+ FileInputStream stream = new FileInputStream(filePath);
+ loadXML(stream, clean);
+ stream.close();
} catch(final java.io.FileNotFoundException e) {
Logger.error(this, "Unable to load XML:
FileNotFoundException ('"+filePath+"') ! : "+e.toString());
+ } catch(java.io.IOException e) {
+ Logger.error(this, "IOException while parsing the
index: "+e.toString());
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
2007-10-28 22:12:19 UTC (rev 15629)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
2007-10-29 00:19:53 UTC (rev 15630)
@@ -5,6 +5,7 @@
import java.util.Date;
import java.util.Vector;
+import java.util.Iterator;
import thaw.fcp.*;
import thaw.plugins.signatures.Identity;
@@ -14,6 +15,8 @@
import thaw.plugins.miniFrost.interfaces.Attachment;
import thaw.core.I18n;
+import thaw.core.ThawRunnable;
+import thaw.core.ThawThread;
public class KSKDraft
implements thaw.plugins.miniFrost.interfaces.Draft, Observer {
@@ -147,8 +150,54 @@
synchronized(board) {
board.addObserver(this);
board.refresh(2 /* until yesterday ; just to be sure
because of the GMT conversion etc */);
+ }
- KSKMessageParser generator = new KSKMessageParser(
((inReplyTo != null) ?
+ /* first check */
+ update(board, null);
+ }
+
+
+ private class InsertionStarter implements ThawRunnable {
+ private boolean forceStop;
+
+ public InsertionStarter() {
+ forceStop = false;
+ }
+
+ public void run() {
+ boolean ready = false;
+
+ while(!ready && attachments != null && !forceStop) {
+ ready = true;
+
+ for (Iterator it = attachments.iterator();
+ it.hasNext();) {
+ KSKAttachment a =
(KSKAttachment)it.next();
+ if (!a.isReady())
+ ready = false;
+ }
+
+ if (!ready) {
+ try {
+ Thread.sleep(500);
+ } catch(InterruptedException e) {
+ /* \_o< */
+ }
+ }
+ }
+
+ if (!forceStop)
+ startInsertion();
+ }
+
+ public void stop() {
+ forceStop = true;
+ }
+ }
+
+ private void startInsertion() {
+ /* we generate first the XML message */
+ KSKMessageParser generator = new KSKMessageParser( ((inReplyTo
!= null) ?
inReplyTo.getMsgId() :
null),
nick,
@@ -165,15 +214,9 @@
idLinePos,
idLineLen);
- fileToInsert = generator.generateXML();
- }
-
- /* first check */
- update(board, null);
- }
-
-
- private void startInsertion() {
+ fileToInsert = generator.generateXML();
+
+
waiting = false;
posting = true;
notifyPlugin();
@@ -227,7 +270,9 @@
board.deleteObserver(this);
revUsed = board.getNextNonDownloadedRev(date,
-1);
- startInsertion();
+
+ ThawThread th = new ThawThread(new
InsertionStarter(), "Frost message insertion starter");
+ th.start();
}
}