mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-06-29 04:28:10 +03:00
[FIX] Probably fix access profileMap with multiple threads
This commit is contained in:
parent
b149686abd
commit
101d8c7275
1 changed files with 3 additions and 2 deletions
|
@ -23,6 +23,7 @@
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class LocalProfilesProvider extends ProfilesProvider implements Reconfigurable {
|
public class LocalProfilesProvider extends ProfilesProvider implements Reconfigurable {
|
||||||
|
@ -196,7 +197,7 @@ private void readCache(Path file) throws IOException {
|
||||||
|
|
||||||
public void readProfilesDir() throws IOException {
|
public void readProfilesDir() throws IOException {
|
||||||
Path profilesDirPath = Path.of(profilesDir);
|
Path profilesDirPath = Path.of(profilesDir);
|
||||||
Map<UUID, LocalProfile> newProfiles = new HashMap<>();
|
Map<UUID, LocalProfile> newProfiles = new ConcurrentHashMap<>();
|
||||||
IOHelper.walk(profilesDirPath, new ProfilesFileVisitor(newProfiles), false);
|
IOHelper.walk(profilesDirPath, new ProfilesFileVisitor(newProfiles), false);
|
||||||
profilesMap = newProfiles;
|
profilesMap = newProfiles;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +219,7 @@ public void readUpdatesDir() throws IOException {
|
||||||
|
|
||||||
public void sync(Collection<String> dirs) throws IOException {
|
public void sync(Collection<String> dirs) throws IOException {
|
||||||
logger.info("Syncing updates dir");
|
logger.info("Syncing updates dir");
|
||||||
Map<String, HashedDir> newUpdatesDirMap = new HashMap<>(16);
|
Map<String, HashedDir> newUpdatesDirMap = new ConcurrentHashMap<>(16);
|
||||||
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(Path.of(updatesDir))) {
|
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(Path.of(updatesDir))) {
|
||||||
for (final Path updateDir : dirStream) {
|
for (final Path updateDir : dirStream) {
|
||||||
if (Files.isHidden(updateDir))
|
if (Files.isHidden(updateDir))
|
||||||
|
|
Loading…
Reference in a new issue