mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 03:32:22 -05:00
Another fix from Dan Foody: improve dumpICS debug option
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@771 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
cb1efbe973
commit
f5bafdbc6a
@ -162,7 +162,7 @@ public final class Settings {
|
|||||||
public static String getLogFileDirectory() {
|
public static String getLogFileDirectory() {
|
||||||
String logFilePath = getLogFilePath();
|
String logFilePath = getLogFilePath();
|
||||||
if (logFilePath == null || logFilePath.length() == 0) {
|
if (logFilePath == null || logFilePath.length() == 0) {
|
||||||
return "";
|
return ".";
|
||||||
}
|
}
|
||||||
int lastSlashIndex = logFilePath.lastIndexOf('/');
|
int lastSlashIndex = logFilePath.lastIndexOf('/');
|
||||||
if (lastSlashIndex == -1) {
|
if (lastSlashIndex == -1) {
|
||||||
@ -171,7 +171,7 @@ public final class Settings {
|
|||||||
if (lastSlashIndex >= 0) {
|
if (lastSlashIndex >= 0) {
|
||||||
return logFilePath.substring(0, lastSlashIndex);
|
return logFilePath.substring(0, lastSlashIndex);
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return ".";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1726,14 +1726,46 @@ public class ExchangeSession {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int dumpIndex = 1;
|
private static int dumpIndex;
|
||||||
private String defaultSound = "Basso";
|
private String defaultSound = "Basso";
|
||||||
|
|
||||||
protected void dumpICS(String icsBody, boolean fromServer, boolean after) {
|
protected void dumpICS(String icsBody, boolean fromServer, boolean after) {
|
||||||
|
String logFileDirectory = Settings.getLogFileDirectory();
|
||||||
|
|
||||||
// additional setting to activate ICS dump (not available in GUI)
|
// additional setting to activate ICS dump (not available in GUI)
|
||||||
if (Settings.getBooleanProperty("davmail.dumpICS")) {
|
int dumpMax = Settings.getIntProperty("davmail.dumpICS");
|
||||||
|
if (dumpMax > 0) {
|
||||||
|
if (dumpIndex > dumpMax) {
|
||||||
|
// Delete the oldest dump file
|
||||||
|
final int oldest = dumpIndex - dumpMax;
|
||||||
|
try {
|
||||||
|
File[] oldestFiles = (new File(logFileDirectory)).listFiles(new FilenameFilter() {
|
||||||
|
public boolean accept(File dir, String name) {
|
||||||
|
if (name.endsWith(".ics")) {
|
||||||
|
int dashIndex = name.indexOf('-');
|
||||||
|
if (dashIndex > 0) {
|
||||||
|
try {
|
||||||
|
int fileIndex = Integer.parseInt(name.substring(0, dashIndex));
|
||||||
|
return fileIndex < oldest;
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (File file : oldestFiles) {
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOGGER.warn("Error deleting ics dump: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder filePath = new StringBuilder();
|
StringBuilder filePath = new StringBuilder();
|
||||||
filePath.append(Settings.getLogFileDirectory()).append('/')
|
filePath.append(logFileDirectory).append('/')
|
||||||
.append(dumpIndex)
|
.append(dumpIndex)
|
||||||
.append(after ? "-to" : "-from")
|
.append(after ? "-to" : "-from")
|
||||||
.append((after ^ fromServer) ? "-server" : "-client")
|
.append((after ^ fromServer) ? "-server" : "-client")
|
||||||
|
Loading…
Reference in New Issue
Block a user