Return-Path: X-Original-To: apmail-ant-notifications-archive@minotaur.apache.org Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2BB499A32 for ; Tue, 17 Apr 2012 15:30:48 +0000 (UTC) Received: (qmail 32767 invoked by uid 500); 17 Apr 2012 15:30:48 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 32733 invoked by uid 500); 17 Apr 2012 15:30:48 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 32726 invoked by uid 99); 17 Apr 2012 15:30:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Apr 2012 15:30:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.115] (HELO eir.zones.apache.org) (140.211.11.115) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Apr 2012 15:30:46 +0000 Received: by eir.zones.apache.org (Postfix, from userid 80) id 8F5613B84; Tue, 17 Apr 2012 15:30:26 +0000 (UTC) From: bugzilla@apache.org To: notifications@ant.apache.org Subject: DO NOT REPLY [Bug 53095] New: Copy issue ant 1.8.2 windows (Failed copy deletes targeted file even when copy is not attempted) Date: Tue, 17 Apr 2012 15:30:24 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ant X-Bugzilla-Component: Core tasks X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jweinste@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: notifications@ant.apache.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: https://issues.apache.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org https://issues.apache.org/bugzilla/show_bug.cgi?id=53095 Bug #: 53095 Summary: Copy issue ant 1.8.2 windows (Failed copy deletes targeted file even when copy is not attempted) Product: Ant Version: 1.8.2 Platform: PC OS/Version: Windows XP Status: NEW Severity: normal Priority: P2 Component: Core tasks AssignedTo: notifications@ant.apache.org ReportedBy: jweinste@gmail.com Classification: Unclassified Copy issue ant 1.8.2 windows (Failed copy deletes targeted file even when copy is not attempted) In this case uses "overwrite" but not "force". Using "force=true" also acts as workaround. 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. If the file is not to be copied to the target file, then the target file should not be deleted. 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())) { -- file is deleted when canWrite false, "read-only" file is not a corrupt file, canWrite is false but delete succeeds 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); -- "read-only" exception, canWrite false } -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.