Fix browser race condition

This commit is contained in:
crschnick 2023-06-09 15:53:50 +00:00
parent 20b96d7f25
commit 73e351d5ef
2 changed files with 5 additions and 3 deletions

View file

@ -306,22 +306,21 @@ public final class OpenFileSystemModel {
this.fileSystem = fs;
this.local =
fs.getShell().map(shellControl -> shellControl.isLocal()).orElse(false);
this.initState();
this.cache.init();
});
}
public void initWithGivenDirectory(String dir) throws Exception {
initState();
cdSyncWithoutCheck(dir);
}
public void initWithDefaultDirectory() throws Exception {
initState();
savedState.cd(null);
history.updateCurrent(null);
}
private void initState() {
void initState() {
this.savedState = OpenFileSystemSavedState.loadForStore(this);
}

View file

@ -71,6 +71,9 @@ public class OpenFileSystemSavedState {
.constructCollectionLikeType(List.class, RecentEntry.class);
List<RecentEntry> recentDirectories =
JacksonMapper.getDefault().treeToValue(tree.remove("recentDirectories"), javaType);
if (recentDirectories == null) {
recentDirectories = List.of();
}
var cleaned = recentDirectories.stream()
.map(recentEntry -> new RecentEntry(FileNames.toDirectory(recentEntry.directory), recentEntry.time))
.filter(distinctBy(recentEntry -> recentEntry.getDirectory()))