From ca67671dc8c6361f1f8e3e8eaa9d025315aef2a4 Mon Sep 17 00:00:00 2001 From: Clement Escoffier Date: Wed, 2 Jul 2014 07:50:15 +0200 Subject: [PATCH] Check that the assets directory exists before retrieving its content (#13) Signed-off-by: Clement Escoffier --- .../org/wisdom/resources/AssetController.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/framework/resource-controller/src/main/java/org/wisdom/resources/AssetController.java b/framework/resource-controller/src/main/java/org/wisdom/resources/AssetController.java index 28f748f4c..54f993f88 100644 --- a/framework/resource-controller/src/main/java/org/wisdom/resources/AssetController.java +++ b/framework/resource-controller/src/main/java/org/wisdom/resources/AssetController.java @@ -132,17 +132,19 @@ private Asset getAssetFromFS(String path) { @Override public Collection> assets() { HashMap> map = new HashMap<>(); - // First insert the FS assets - // For this iterate over the file present on the file system. - Collection files = FileUtils.listFiles(directory, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); - for (File file : files) { - if (file.getName().startsWith(".")) { - // Skip file starting with . - continue; + if (directory.isDirectory()) { + // First insert the FS assets + // For this iterate over the file present on the file system. + Collection files = FileUtils.listFiles(directory, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); + for (File file : files) { + if (file.getName().startsWith(".")) { + // Skip file starting with . + continue; + } + String path = "/assets" + file.getAbsolutePath().substring(directory.getAbsolutePath().length()); + // TODO Do we really need computing the ETAG here ? + map.put(path, new DefaultAsset<>(path, file, file.getAbsolutePath(), file.lastModified(), null)); } - String path = "/assets" + file.getAbsolutePath().substring(directory.getAbsolutePath().length()); - // TODO Do we really need computing the ETAG here ? - map.put(path, new DefaultAsset<>(path, file, file.getAbsolutePath(), file.lastModified(), null)); } // No add the bundle things.