mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Fix
This commit is contained in:
parent
384a28c517
commit
4a594a8e4f
@ -40,6 +40,8 @@ import lombok.Data;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
protected String folderName;
|
protected String folderName;
|
||||||
protected String resourceTypeName;
|
protected String resourceTypeName;
|
||||||
protected KCache<String, T> loadCache;
|
protected KCache<String, T> loadCache;
|
||||||
protected KList<File> folderCache;
|
protected final AtomicReference<KList<File>> folderCache;
|
||||||
protected Class<? extends T> objectClass;
|
protected Class<? extends T> objectClass;
|
||||||
protected String cname;
|
protected String cname;
|
||||||
protected String[] possibleKeys = null;
|
protected String[] possibleKeys = null;
|
||||||
@ -61,6 +63,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
|
|
||||||
public ResourceLoader(File root, IrisData manager, String folderName, String resourceTypeName, Class<? extends T> objectClass) {
|
public ResourceLoader(File root, IrisData manager, String folderName, String resourceTypeName, Class<? extends T> objectClass) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
folderCache = new AtomicReference<>();
|
||||||
sec = new ChronoLatch(5000);
|
sec = new ChronoLatch(5000);
|
||||||
loads = new AtomicInteger();
|
loads = new AtomicInteger();
|
||||||
this.objectClass = objectClass;
|
this.objectClass = objectClass;
|
||||||
@ -268,26 +271,20 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public KList<File> getFolders() {
|
public KList<File> getFolders() {
|
||||||
if (folderCache == null) {
|
if (folderCache.get() == null) {
|
||||||
folderCache = new KList<>();
|
folderCache.set(new KList<>());
|
||||||
|
|
||||||
for (File i : root.listFiles()) {
|
for (File i : root.listFiles()) {
|
||||||
if (i.isDirectory()) {
|
if (i.isDirectory()) {
|
||||||
if (i.getName().equals(folderName)) {
|
if (i.getName().equals(folderName)) {
|
||||||
folderCache.add(i);
|
folderCache.get().add(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (folderCache == null) {
|
return folderCache.get();
|
||||||
synchronized (this) {
|
|
||||||
return getFolderCache();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return folderCache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<File> getFolders(String rc) {
|
public KList<File> getFolders(String rc) {
|
||||||
@ -307,7 +304,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
possibleKeys = null;
|
possibleKeys = null;
|
||||||
loadCache.invalidate();
|
loadCache.invalidate();
|
||||||
folderCache = null;
|
folderCache.set(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File fileFor(T b) {
|
public File fileFor(T b) {
|
||||||
@ -333,7 +330,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clearList() {
|
public void clearList() {
|
||||||
folderCache = null;
|
folderCache.set(null);
|
||||||
possibleKeys = null;
|
possibleKeys = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user