From 82a43b48cba77a1e4fe108732838f32c710e8831 Mon Sep 17 00:00:00 2001
From: Andrew Su <asu@redhat.com>
Date: Wed, 25 May 2011 14:50:42 -0400
Subject: Fix PR726. Create recently_used on startup.

---
 netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

(limited to 'netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java')

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