Mercurial Hosting > luan
changeset 1501:e66e3d50b289
mkdirs
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 10 May 2020 22:28:13 -0600 |
parents | f01abd6d5858 |
children | 8a7b6b32c691 |
files | src/goodjava/io/IoUtils.java src/goodjava/lucene/backup/Backup.java src/goodjava/lucene/backup/BackupIndexWriter.java src/goodjava/lucene/backup/BackupServer.java src/goodjava/lucene/logging/LoggingIndexWriter.java src/luan/host/WebHandler.java src/luan/modules/IoLuan.java |
diffstat | 7 files changed, 19 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/goodjava/io/IoUtils.java Sun May 10 13:06:11 2020 -0600 +++ b/src/goodjava/io/IoUtils.java Sun May 10 22:28:13 2020 -0600 @@ -18,6 +18,10 @@ Files.deleteIfExists( file.toPath() ); } + public static void mkdirs(File file) throws IOException { + Files.createDirectories( file.toPath() ); + } + public static boolean isSymbolicLink(File file) { return Files.isSymbolicLink(file.toPath()); }
--- a/src/goodjava/lucene/backup/Backup.java Sun May 10 13:06:11 2020 -0600 +++ b/src/goodjava/lucene/backup/Backup.java Sun May 10 22:28:13 2020 -0600 @@ -37,7 +37,7 @@ } void handle2(RpcServer rpc,RpcCall call) throws IOException { - dir.mkdirs(); + IoUtils.mkdirs(dir); //logger.info(call.cmd+" "+Arrays.asList(call.args)); String fileName = null; if( call.cmd.equals("check") ) {
--- a/src/goodjava/lucene/backup/BackupIndexWriter.java Sun May 10 13:06:11 2020 -0600 +++ b/src/goodjava/lucene/backup/BackupIndexWriter.java Sun May 10 22:28:13 2020 -0600 @@ -37,7 +37,7 @@ this.name = name; File f = new File(System.getProperty("java.io.tmpdir")); dir = new File(f,"goodjava.lucene/"+name); - dir.mkdirs(); + IoUtils.mkdirs(dir); } public synchronized void commit() throws IOException {
--- a/src/goodjava/lucene/backup/BackupServer.java Sun May 10 13:06:11 2020 -0600 +++ b/src/goodjava/lucene/backup/BackupServer.java Sun May 10 22:28:13 2020 -0600 @@ -10,6 +10,7 @@ import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLServerSocket; import goodjava.util.SoftCacheMap; +import goodjava.io.IoUtils; import goodjava.rpc.RpcServer; import goodjava.rpc.RpcCall; import goodjava.logging.Logger; @@ -41,9 +42,9 @@ private static final ThreadPoolExecutor threadPool = (ThreadPoolExecutor)Executors.newCachedThreadPool(); private static final Map<String,Backup> backups = new SoftCacheMap<String,Backup>(); - public BackupServer(File backupDir) { + public BackupServer(File backupDir) throws IOException { this.backupDir = backupDir; - backupDir.mkdirs(); + IoUtils.mkdirs(backupDir); } public synchronized void start() throws IOException {
--- a/src/goodjava/lucene/logging/LoggingIndexWriter.java Sun May 10 13:06:11 2020 -0600 +++ b/src/goodjava/lucene/logging/LoggingIndexWriter.java Sun May 10 22:28:13 2020 -0600 @@ -54,7 +54,7 @@ public LoggingIndexWriter(LuceneIndexWriter indexWriter,File logDir) throws IOException { this.indexWriter = indexWriter; this.logDir = logDir; - logDir.mkdirs(); + IoUtils.mkdirs(logDir); if( !logDir.isDirectory() ) throw new RuntimeException(); index = new File(logDir,"index");
--- a/src/luan/host/WebHandler.java Sun May 10 13:06:11 2020 -0600 +++ b/src/luan/host/WebHandler.java Sun May 10 22:28:13 2020 -0600 @@ -1,8 +1,10 @@ package luan.host; import java.io.File; +import java.io.IOException; import goodjava.logging.Logger; import goodjava.logging.LoggerFactory; +import goodjava.io.IoUtils; import goodjava.webserver.Handler; import goodjava.webserver.Request; import goodjava.webserver.Response; @@ -28,7 +30,11 @@ String dirStr = dir.toString(); String logDir = dirStr + "/site/private/local/logs/web"; - new File(logDir).mkdirs(); + try { + IoUtils.mkdirs(new File(logDir)); + } catch(IOException e) { + throw new RuntimeException(e); + } Luan luan = new Luan(); initLuan(luan,dirStr,domain);
--- a/src/luan/modules/IoLuan.java Sun May 10 13:06:11 2020 -0600 +++ b/src/luan/modules/IoLuan.java Sun May 10 22:28:13 2020 -0600 @@ -487,11 +487,8 @@ IoUtils.deleteRecursively(file); } - public void mkdir() throws LuanException { - if( !file.isDirectory() ) { - if( !file.mkdirs() ) - throw new LuanException("couldn't make directory "+file); - } + public void mkdir() throws IOException { + IoUtils.mkdirs(file); } public void set_last_modified(long time) throws LuanException {