On Sun, Jun 29, 2008 at 5:33 AM, <toad at freenetproject.org> wrote:
> Author: toad
> Date: 2008-06-28 21:33:39 +0000 (Sat, 28 Jun 2008)
> New Revision: 20865
>
> Modified:
> branches/db4o/freenet/src/freenet/node/fcp/FCPServer.java
> Log:
> Fix renaming
>
Should we use FileUtil#renameTo() ?
> Modified: branches/db4o/freenet/src/freenet/node/fcp/FCPServer.java
> ===================================================================
> --- branches/db4o/freenet/src/freenet/node/fcp/FCPServer.java 2008-06-28
> 21:24:47 UTC (rev 20864)
> +++ branches/db4o/freenet/src/freenet/node/fcp/FCPServer.java 2008-06-28
> 21:33:39 UTC (rev 20865)
> @@ -866,18 +866,28 @@
>
> if(enablePersistentDownloads) {
> boolean movedMain = false;
> + if(logMINOR) {
> + Logger.minor(this, "Persistent downloads file
> should be "+persistentDownloadsFile);
> + Logger.minor(this, "Persistent downloads temp
> file should be "+persistentDownloadsTempFile);
> + }
> + File from = new
> File(persistentDownloadsFile.getPath()+".gz");
> + File fromTemp = new
> File(persistentDownloadsTempFile.getPath()+".gz");
> // Rename
> - if(persistentDownloadsFile.exists()) {
> - File target = new
> File(persistentDownloadsFile.getPath()+".old.pre-db4o");
> - if(persistentDownloadsFile.renameTo(target)) {
> - Logger.error(this, "Successfully
> migrated persistent downloads and renamed
> "+persistentDownloadsFile.getName()+" to "+target.getName());
> + if(from.exists()) {
> + File target = new
> File(from.getPath()+".old.pre-db4o");
> + if(logMINOR)
> + Logger.minor(this, "Trying to move
> "+persistentDownloadsFile+" to "+target);
> + if(from.renameTo(target)) {
> + Logger.error(this, "Successfully
> migrated persistent downloads and renamed "+from.getName()+" to
> "+target.getName());
> movedMain = true;
> }
> }
> - if(persistentDownloadsTempFile.exists()) {
> - File target = new
> File(persistentDownloadsFile.getPath()+".old.pre-db4o");
> - if(persistentDownloadsFile.renameTo(target)
> && !movedMain)
> - Logger.error(this, "Successfully
> migrated persistent downloads and renamed
> "+persistentDownloadsFile.getName()+" to "+target.getName());
> + if(fromTemp.exists()) {
> + File target = new
> File(fromTemp.getPath()+".old.pre-db4o");
> + if(logMINOR)
> + Logger.minor(this, "Trying to move
> "+fromTemp+" to "+target);
> + if(fromTemp.renameTo(target) && !movedMain)
> + Logger.error(this, "Successfully
> migrated persistent downloads and renamed "+fromTemp.getName()+" to
> "+target.getName());
> }
>
> }
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>