1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2024-11-24 12:16:28 +01:00

Made InstallLog synchronized.

This commit is contained in:
sk89q 2014-01-08 18:59:31 -08:00
parent b42698f877
commit 4c635b6e0a

View File

@ -28,7 +28,7 @@ public class InstallLog {
@JsonIgnore @JsonIgnore
private Set<String> cache = new HashSet<String>(); private Set<String> cache = new HashSet<String>();
public void add(@NonNull String group, @NonNull String entry) { public synchronized void add(@NonNull String group, @NonNull String entry) {
cache.add(entry); cache.add(entry);
Set<String> subEntries = entries.get(group); Set<String> subEntries = entries.get(group);
if (subEntries == null) { if (subEntries == null) {
@ -38,19 +38,19 @@ public class InstallLog {
subEntries.add(entry); subEntries.add(entry);
} }
public void add(@NonNull File group, @NonNull File entry) { public synchronized void add(@NonNull File group, @NonNull File entry) {
add(relativize(group), relativize(entry)); add(relativize(group), relativize(entry));
} }
public boolean has(@NonNull String entry) { public synchronized boolean has(@NonNull String entry) {
return cache.contains(entry); return cache.contains(entry);
} }
public boolean has(@NonNull File entry) { public synchronized boolean has(@NonNull File entry) {
return has(relativize(entry)); return has(relativize(entry));
} }
public boolean copyGroupFrom(InstallLog other, String group) { public synchronized boolean copyGroupFrom(InstallLog other, String group) {
Set<String> otherSet = other.entries.get(group); Set<String> otherSet = other.entries.get(group);
if (otherSet == null) { if (otherSet == null) {
return false; return false;
@ -61,16 +61,16 @@ public class InstallLog {
return true; return true;
} }
public boolean copyGroupFrom(@NonNull InstallLog other, @NonNull File entry) { public synchronized boolean copyGroupFrom(@NonNull InstallLog other, @NonNull File entry) {
return copyGroupFrom(other, relativize(entry)); return copyGroupFrom(other, relativize(entry));
} }
@JsonIgnore @JsonIgnore
public Set<Map.Entry<String, Set<String>>> getEntrySet() { public synchronized Set<Map.Entry<String, Set<String>>> getEntrySet() {
return entries.entrySet(); return entries.entrySet();
} }
public boolean hasGroup(String group) { public synchronized boolean hasGroup(String group) {
return entries.containsKey(group); return entries.containsKey(group);
} }