From 30a7de374c944fe797424424e0355d286ee845e6 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Fri, 1 May 2020 13:17:39 +0200 Subject: [PATCH] CacheLib: better lock --- src/be/nikiroo/fanfix/library/CacheLibrary.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/be/nikiroo/fanfix/library/CacheLibrary.java b/src/be/nikiroo/fanfix/library/CacheLibrary.java index 92e4ae7a..a3c3b5e3 100644 --- a/src/be/nikiroo/fanfix/library/CacheLibrary.java +++ b/src/be/nikiroo/fanfix/library/CacheLibrary.java @@ -67,6 +67,7 @@ public class CacheLibrary extends BasicLibrary { pg = new Progress(); } + List copy; synchronized (metasLock) { // We make sure that cached metas have precedence if (metasMixed == null) { @@ -86,10 +87,12 @@ public class CacheLibrary extends BasicLibrary { } } } + + copy = new ArrayList(metasMixed); } pg.done(); - return new ArrayList(metasMixed); + return copy; } @Override @@ -404,9 +407,7 @@ public class CacheLibrary extends BasicLibrary { MetaData meta = lib.imprt(url, pgImprt); updateMetaCache(metasReal, meta); - synchronized (metasLock) { - metasMixed = null; - } + metasMixed = null; clearFromCache(meta.getLuid()); -- 2.27.0