diff --git a/src/main/java/org/nachc/tools/githubbackup/util/backup/DeleteOlderThanOneMonth.java b/src/main/java/org/nachc/tools/githubbackup/util/backup/DeleteOlderThanOneMonth.java index 982df4c..b4e5553 100644 --- a/src/main/java/org/nachc/tools/githubbackup/util/backup/DeleteOlderThanOneMonth.java +++ b/src/main/java/org/nachc/tools/githubbackup/util/backup/DeleteOlderThanOneMonth.java @@ -32,7 +32,7 @@ public static void exec(BufferedWriter writer) { String fileName = file.getName(); log.info("FILE: " + fileName); writer.append("\nFILE: " + fileName); - if("MONTHLY".equals(fileName) == false && "github-backup".equals(fileName) == false && file.isDirectory() && fileName.contains(thisMonth) == false) { + if("MONTHLY".equals(fileName) == false && "github-backup".equals(fileName) == false && file.isDirectory() && fileName.startsWith(thisMonth) == false) { log.info("!!!REMOVING!!!"); writer.append("\n!!!REMOVING!!!"); FileUtil.rmdir(file); @@ -49,14 +49,14 @@ public static void exec(BufferedWriter writer) { private static String getThisMonth() { Calendar cal = Calendar.getInstance(); - String rtn = TimeUtil.format(cal.getTime(), "yyyy_MM"); + String rtn = TimeUtil.format(cal.getTime(), "yyyy_MM_"); return rtn; } private static String getLastMonth() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, -1); - String rtn = TimeUtil.format(cal.getTime(), "yyyy_MM"); + String rtn = TimeUtil.format(cal.getTime(), "yyyy_MM_"); return rtn; }