Return-Path: X-Original-To: apmail-ant-user-archive@www.apache.org Delivered-To: apmail-ant-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6850A933A for ; Thu, 12 Apr 2012 04:48:51 +0000 (UTC) Received: (qmail 34377 invoked by uid 500); 12 Apr 2012 04:48:50 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 33962 invoked by uid 500); 12 Apr 2012 04:48:49 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 46612 invoked by uid 99); 11 Apr 2012 17:23:11 -0000 X-ASF-Spam-Status: No, hits=-2.8 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_HI,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jason.weinstein@oracle.com designates 141.146.126.227 as permitted sender) Message-ID: <4F85BDF7.6000703@oracle.com> Date: Wed, 11 Apr 2012 10:23:03 -0700 From: Jason Weinstein Organization: Oracle Corporation User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: user@ant.apache.org Subject: Copy issue ant 1.8.2 windows (Failed copy deletes targeted file even when copy is not attempted) Content-Type: multipart/alternative; boundary="------------000502080806050703040000" X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090208.4F85BDE3.00A2,ss=1,re=0.000,fgs=0 X-Virus-Checked: Checked by ClamAV on apache.org --------------000502080806050703040000 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit NOTE: I attempted subscription to ant user mailing list but have not yet received a subscribe email ack, so PLEASE include jason.weinstein@oracle.com in responses. Thanks Copy issue ant 1.8.2 windows (Failed copy deletes targeted file even when copy is not attempted) copy uses overwrite but not force. Is this fixed perhaps in 1.8.3? Should a bug be created? Any workarounds? What I assume is happening based on code is targeted file canWrite fails, read-only exception is thrown, and then targeted file is deleted, which succeeds. The later part is what i observe, read-only exception followed by file deletion. This is not the behavior i would expect. Copy.java protected void doResourceOperations(Map map) { if (map.size() > 0) { log("Copying " + map.size() + " resource" + (map.size() == 1 ? "" : "s") + " to " + this.destDir.getAbsolutePath()); Iterator iter = map.keySet().iterator(); while (iter.hasNext()) { Resource fromResource = (Resource)iter.next(); String[] toFiles = (String[])map.get(fromResource); for (int i = 0; i < toFiles.length; i++) { String toFile = toFiles[i]; try { log("Copying " + fromResource + " to " + toFile, this.verbosity); FilterSetCollection executionFilters = new FilterSetCollection(); if (this.filtering) { executionFilters.addFilterSet(getProject().getGlobalFilterSet()); } Enumeration filterEnum = this.filterSets.elements(); while (filterEnum.hasMoreElements()) { executionFilters.addFilterSet((FilterSet)filterEnum.nextElement()); } ResourceUtils.copyResource(fromResource, new FileResource(this.destDir, toFile), executionFilters, this.filterChains, this.forceOverwrite, this.preserveLastModified, false, this.inputEncoding, this.outputEncoding, getProject(), getForce()); } catch (IOException ioe) { String msg = "Failed to copy " + fromResource + " to " + toFile + " due to " + getDueTo(ioe); File targetFile = new File(toFile); if ((targetFile.exists()) && (!targetFile.delete())) { msg = msg + " and I couldn't delete the corrupt " + toFile; } if (this.failonerror) { throw new BuildException(msg, ioe, getLocation()); } log(msg, 0); } ResourceUtils.java#copyResource File destFile = null; if (dest.as(FileProvider.class) != null) { destFile = ((FileProvider)dest.as(FileProvider.class)).getFile(); } if ((destFile != null) && (destFile.isFile()) && (!destFile.canWrite())) { if (!force) { throw new IOException("can't write to read-only destination file " + destFile); } --------------000502080806050703040000--