From 5d4b86fa9837492193f29c21d9dd3518fd6d06b3 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Thu, 22 Jul 2010 14:21:05 +0000 Subject: QPID-2739 : Updated deleteFile to add the backupFilesToPath for delete requests if it is set. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@966677 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/log4j/QpidCompositeRollingAppender.java | 39 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'java/broker/src/main') diff --git a/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java b/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java index be52b82789..1ad04af274 100644 --- a/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java +++ b/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java @@ -674,10 +674,43 @@ public class QpidCompositeRollingAppender extends FileAppender } } - /** Delete's the specified file if it exists */ - protected void deleteFile(String fileName) + /** + * Delete the given file that is prepended with the relative path to the log + * directory. + * + * Compress is enabled check for file with COMPRESS_EXTENSION(.gz) + * + * if backupFilesToPath is set then check in this directory not the + * main log directory. + */ + protected void deleteFile(String relativeFileName) { - File file = compress ? new File(fileName + COMPRESS_EXTENSION) : new File(fileName); + String fileName=""; + // If we have configured a backup location then we should look in there + // for the file we are trying to delete + if (backupFilesToPath != null) + { + int index = relativeFileName.lastIndexOf(File.separator); + if (index != -1) + { + fileName = backupFilesToPath + File.separator + + relativeFileName.substring(index); + } + else + { + fileName = relativeFileName; + } + } + + // If we are compressing the at the extension + if (compress) + { + fileName += COMPRESS_EXTENSION; + } + + + File file = new File(fileName); + if (file.exists()) { file.delete(); -- cgit v1.2.1