From 82a43b48cba77a1e4fe108732838f32c710e8831 Mon Sep 17 00:00:00 2001 From: Andrew Su Date: Wed, 25 May 2011 14:50:42 -0400 Subject: Fix PR726. Create recently_used on startup. --- ChangeLog | 6 ++++++ netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a25250..41f38d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-05-20 Andrew Su + + * netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java: + (CacheLRUWrapper): New constructor to create file. + (lock): Removed creation of file here. + 2011-05-17 Jiri Vanek * tests/junit-runner/JunitLikeXmlOutputListener: This listener exports diff --git a/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java b/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java index 2a91456..59ab00d 100644 --- a/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java +++ b/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java @@ -78,6 +78,18 @@ enum CacheLRUWrapper { private PropertiesFile cacheOrder = new PropertiesFile( new File(cacheDir + File.separator + "recently_used")); + private CacheLRUWrapper(){ + File f = cacheOrder.getStoreFile(); + if (!f.exists()) { + try { + FileUtils.createParentDir(f); + FileUtils.createRestrictedFile(f, true); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + /** * Returns an instance of the policy. * @@ -181,12 +193,7 @@ enum CacheLRUWrapper { */ public synchronized void lock() { try { - File f = cacheOrder.getStoreFile(); - if (!f.exists()) { - FileUtils.createParentDir(f); - FileUtils.createRestrictedFile(f, true); - } - fl = FileUtils.getFileLock(f.getPath(), false, true); + fl = FileUtils.getFileLock(cacheOrder.getStoreFile().getPath(), false, true); } catch (OverlappingFileLockException e) { // if overlap we just increase the count. } catch (Exception e) { // We didn't get a lock.. e.printStackTrace(); -- cgit v1.2.3