From 7d868d2e29dd486468694de73f7293ddddaa030b Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 6 Feb 2003 16:19:22 +0000 Subject: [PATCH] Try to clean up after a failed copy. PR: 16768 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274008 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/taskdefs/Copy.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java index cf25743ae..fc67650cb 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -531,6 +531,10 @@ public class Copy extends Task { } catch (IOException ioe) { String msg = "Failed to copy " + fromFile + " to " + toFile + " due to " + ioe.getMessage(); + File targetFile = new File(toFile); + if (targetFile.exists() && !targetFile.delete()) { + msg += " and I couldn't delete the corrupt " + toFile; + } throw new BuildException(msg, ioe, getLocation()); } }