From b56144731245467e9663415db48f71021337abca Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 16 Apr 2004 09:35:21 +0000 Subject: [PATCH] Don't delete existing file when trying to update a read-only archive, PR: 28419 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276327 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 5 ++++- src/main/org/apache/tools/ant/taskdefs/Zip.java | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/WHATSNEW b/WHATSNEW index f3032b4c8..5b2bff393 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -114,7 +114,10 @@ Fixed bugs: behaved identically. * now sets the context classloader if you've specified a nested - . Bugzilla report 24802. + . Bugzilla Report 24802. + +* and friends would delete the original file when trying to update + a read-only archive. Bugzilla Report 28419. Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index e29a0c4e1..be3cfdd84 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -338,6 +338,14 @@ public class Zip extends MatchingTask { + archiveType + " file to create!"); } + if (zipFile.exists() && !zipFile.isFile()) { + throw new BuildException(zipFile + " is not a file."); + } + + if (zipFile.exists() && !zipFile.canWrite()) { + throw new BuildException(zipFile + " is read-only."); + } + // Renamed version of original file, if it exists File renamedFile = null; // Whether or not an actual update is required -