[FIX] pushUpdate: UnsupportedOperationException

This commit is contained in:
Gravita 2025-06-29 04:30:32 +07:00
parent bd0423460f
commit 26c21a3ec7

View file

@ -182,7 +182,7 @@ private void writeCache(Path file) throws IOException {
} }
private void readCache(Path file) throws IOException { private void readCache(Path file) throws IOException {
Map<String, HashedDir> updatesDirMap = new HashMap<>(16); Map<String, HashedDir> updatesDirMap = new ConcurrentHashMap<>(16);
try (HInput input = new HInput(IOHelper.newInput(file))) { try (HInput input = new HInput(IOHelper.newInput(file))) {
int size = input.readLength(0); int size = input.readLength(0);
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
@ -192,7 +192,7 @@ private void readCache(Path file) throws IOException {
} }
} }
logger.debug("Found {} updates from cache", updatesDirMap.size()); logger.debug("Found {} updates from cache", updatesDirMap.size());
this.updatesDirMap = Collections.unmodifiableMap(updatesDirMap); this.updatesDirMap = updatesDirMap;
} }
public void readProfilesDir() throws IOException { public void readProfilesDir() throws IOException {
@ -248,7 +248,7 @@ public void sync(Collection<String> dirs) throws IOException {
newUpdatesDirMap.put(name, updateHDir); newUpdatesDirMap.put(name, updateHDir);
} }
} }
updatesDirMap = Collections.unmodifiableMap(newUpdatesDirMap); updatesDirMap = newUpdatesDirMap;
if (cacheUpdates) { if (cacheUpdates) {
try { try {
writeCache(Path.of(cacheFile)); writeCache(Path.of(cacheFile));