check id parent dir exists for backup

This commit is contained in:
Manfred Karrer 2016-04-13 13:51:40 +02:00
parent b621c86e33
commit 81fcc82972

View file

@ -16,10 +16,11 @@ public class FileUtil {
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
public static void rollingBackup(File dir, String fileName) {
if (dir.exists()) {
File backupDir = new File(Paths.get(dir.getAbsolutePath(), "backup").toString());
if (!backupDir.exists())
if (!backupDir.mkdir())
log.warn("make dir failed");
log.warn("make dir failed.\nBackupDir=" + backupDir.getAbsolutePath());
File origFile = new File(Paths.get(dir.getAbsolutePath(), fileName).toString());
if (origFile.exists()) {
@ -43,6 +44,7 @@ public class FileUtil {
}
}
}
}
private static void pruneBackup(File backupDir) {
if (backupDir.isDirectory()) {