Improved temporary file removing.
This commit is contained in:
parent
d017781858
commit
380028376a
1 changed files with 11 additions and 1 deletions
|
@ -105,9 +105,9 @@ public class Crawler
|
|||
{
|
||||
logger.info("Crawling {}", url);
|
||||
|
||||
File downloadFile = null;
|
||||
try
|
||||
{
|
||||
File downloadFile;
|
||||
try
|
||||
{
|
||||
downloadFile = download(url);
|
||||
|
@ -158,6 +158,7 @@ public class Crawler
|
|||
{
|
||||
logger.error("ERROR: bad child class [{}][{}].", downloadClass, parent);
|
||||
this.journal.add(url, parentURL, CrawlStatus.BADCHILDCLASS);
|
||||
downloadFile.delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -177,6 +178,7 @@ public class Crawler
|
|||
if (StringUtils.equals(downloadSha, storedSha))
|
||||
{
|
||||
this.journal.add(url, parentURL, CrawlStatus.SUCCESS);
|
||||
downloadFile.delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -234,6 +236,13 @@ public class Crawler
|
|||
{
|
||||
this.journal.add(url, parentURL, CrawlStatus.IOERROR);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ((downloadFile != null) && (downloadFile.exists()))
|
||||
{
|
||||
downloadFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -325,6 +334,7 @@ public class Crawler
|
|||
{
|
||||
final int TIMEOUT = 5000;
|
||||
result = Files.createTempFile("tmp-", ".statoolsinfos").toFile();
|
||||
result.deleteOnExit();
|
||||
FileUtils.copyURLToFile(url, result, TIMEOUT, TIMEOUT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue