On Thu, Mar 27, 2003 at 11:48:12AM +0100, panamerica334 at uni.de wrote:
> i hope i'm right assuming this will fix the latest problems:
>
> if not, throw some rocks at me :P
>
> this code is untested, uncompiled and not verified - UAYOR!!
>
PLEASE TEST IT. The code works fine on unix and always has. If it needs
the target file explicitly removing first, then it is yet another of the
platform specificities that java is supposed to shield us from (ARE YOU
LISTENING IAN?). And it's deeply counterproductive; the
write-to-another-file-and-then-rename-over-the-first one is a
pseudo-transactional pattern that is WIDELY used on *nix to ensure that
even if there is a crash there is probably a valid file on disk.
> check it and resubmit to support@ if you feel like it (or simply delete
> this meil ;)
>
> ---~~---
>
> patch for Main.java:
>
> File temp = new File(Node.nodeFile+"-temp");
> File outfile = new File(Node.nodeFile);
>
> OutputStream out =
> new FileOutputStream(temp);
> try {
> fs.writeFields(new WriteOutputStream(out));
> } catch (IOException e) {
> Core.logger.log(Main.class, "Cannot write node file", e,
> Core.logger.ERROR);
> System.err.println("Cannot write node file: "+e);
> e.printStackTrace(System.err);
> } finally {
> out.close();
> }
>
> + if(outfile.exists()) {
> + Core.logger.log(Main.class, "Deleting old node file
> "+outfile, Core.logger.DEBUG);
> + if(!outfile.delete()) {
> + Core.logger.log(Main.class, "Cannot delete old
> node file "+outfile,
> + Core.logger.ERROR);
> + System.err.println("CANNOT DELETE OLD NODE FILE
> "+outfile);
> + }
> + }
> +
> if(!temp.renameTo(outfile)) {
> Core.logger.log(Main.class, "Cannot rename "+temp+" to
> "+outfile,
> Core.logger.ERROR);
> System.err.println("CANNOT RENAME NODE FILE "+temp+" TO
> "+outfile);
> }
> Core.logger.log(Main.class, "Written node file",
> Core.logger.DEBUG);
> }
>
> ---~~---
>
> comments on your log:
>
> >>My log is full of the following error: Cannot rename node-temp to
> >>node.
> >
> >It's the same at my place.
> >
> >Starting with NO "node" file and NO "node-temp" file the debug-level
> >log starts with:
> >
> >27.03.2003 xx:xx:xx (freenet.support.io.Bandwidth, main, NORMAL): new
> >Bandwidth(96000,0,RECEIVED)
> >27.03.2003 xx:xx:xx (freenet.support.io.Bandwidth, main, NORMAL): new
> >Bandwidth(10000,0,SENT)
> >27.03.2003 xx:xx:xx (freenet.node.Main, main, NORMAL): loading node keys:
> >X:\xxxxxxxxxxxxxxx\xxxxxxx\node
> >27.03.2003 xx:xx:xx (freenet.node.Main, main, NORMAL): Creating node
> >keys: X:\xxxxxxxxxxxxxxx\xxxxxxx\node
>
> -> file "node-temp" (N_1) was created and later successfully renamed to
> "node" (N_1)
>
> >27.03.2003 xx:xx:xx (freenet.node.Main, main, ERROR): Cannot rename
> >X:\xxxxxxxxxxxxxxx\xxxxxxx\node-
> >temp to X:\xxxxxxxxxxxxxxx\xxxxxxx\node
>
> -> a new file "node-temp" (N_2) was created but could not renamed to
> "node" because the old "node" (N_1) file still exists
>
> >CANNOT RENAME NODE FILE X:\xxxxxxxxxxxxxxx\xxxxxxx\node-temp TO
> >X:\xxxxxxxxxxxxxxx\xxxxxxx\node
> >27.03.2003 xx:xx:xx (freenet.node.Main, main, NORMAL): starting filesystem
>
> -> again a new node-temp was created (N_3) .... but node (N_1) still
> exists
>
> >[SNIP]
> >
> >The files "node" and "node temp" are created but "node" is never changed!
> >And therefore "ARK.revision" and "ARK.revisionInserted" will always be
> >"=0". The node will have to find free ARK slots on every start-up.
>
> -> because node is still N_1
>
>
>
>
> _______________________________________________
> devl mailing list
> devl at freenetproject.org
> http://hawk.freenetproject.org:8080/cgi-bin/mailman/listinfo/devl
>
--
Matthew Toseland
toad at amphibian.dyndns.org/amphibian at users.sourceforge.net
Full time freenet hacker.
http://freenetproject.org/
Freenet Distribution Node (temporary) at
http://80-192-4-36.cable.ubr09.na.blueyonder.co.uk:8889/BFrv55rtF2w/
ICTHUS.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20030327/82125135/attachment.pgp>