diff --git a/src/fr/devinsy/statoolinfos/crawl/CrawlCache.java b/src/fr/devinsy/statoolinfos/crawl/CrawlCache.java index ef2bd3f..e83c6d1 100644 --- a/src/fr/devinsy/statoolinfos/crawl/CrawlCache.java +++ b/src/fr/devinsy/statoolinfos/crawl/CrawlCache.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Christian Pierre MOMON + * Copyright (C) 2020-2021 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -21,6 +21,7 @@ package fr.devinsy.statoolinfos.crawl; import java.io.File; import java.io.IOException; import java.net.URL; +import java.nio.file.Files; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FileUtils; @@ -389,7 +390,17 @@ public class CrawlCache { final int TIMEOUT = 5000; result = buildFile(url.toString()); - FileUtils.copyURLToFile(url, result, TIMEOUT, TIMEOUT); + File temp = Files.createTempFile("tmp-", ".statoolsinfos").toFile(); + FileUtils.copyURLToFile(url, temp, TIMEOUT, TIMEOUT); + if (temp.length() == 0) + { + logger.warn("WARNING: empty file crawled for [{}]", url); + } + else + { + temp.renameTo(result); + } + temp.delete(); } else {