Browser resilience fixes [stage]

This commit is contained in:
crschnick 2025-04-01 03:48:31 +00:00
parent d5b10793ee
commit 4c454a1b4b
4 changed files with 25 additions and 8 deletions

View file

@ -45,7 +45,6 @@ public final class BrowserFileListComp extends SimpleComp {
private final BrowserFileListModel fileList;
private final StringProperty typedSelection = new SimpleStringProperty("");
private final DoubleProperty ownerWidth = new SimpleDoubleProperty();
public BrowserFileListComp(BrowserFileListModel fileList) {
this.fileList = fileList;
@ -181,6 +180,10 @@ public final class BrowserFileListComp extends SimpleComp {
return null;
}
if (unix.getUid() == null && unix.getGid() == null && unix.getUser() == null && unix.getGroup() == null) {
return null;
}
var m = fileList.getFileSystemModel();
var user = unix.getUser() != null
? unix.getUser()
@ -485,12 +488,16 @@ public final class BrowserFileListComp extends SimpleComp {
mtimeCol.setVisible(true);
}
ownerWidth.set(fileList.getAll().getValue().stream()
var hasOwner = fileList.getAll().getValue().stream()
.map(browserEntry -> formatOwner(browserEntry))
.map(s -> s != null ? s.length() * 9 : 0)
.max(Comparator.naturalOrder())
.orElse(150));
ownerCol.setPrefWidth(ownerWidth.get());
.filter(s -> s != null)
.count() > 0;
if (hasOwner) {
ownerCol.setPrefWidth(fileList.getAll().getValue().stream().map(browserEntry -> formatOwner(browserEntry)).map(
s -> s != null ? s.length() * 9 : 0).max(Comparator.naturalOrder()).orElse(150));
} else {
ownerCol.setPrefWidth(0);
}
if (fileList.getFileSystemModel().getFileSystem() != null) {
var shell = fileList.getFileSystemModel()
@ -503,7 +510,9 @@ public final class BrowserFileListComp extends SimpleComp {
} else {
modeCol.setVisible(true);
if (table.getWidth() > 1000) {
ownerCol.setVisible(true);
ownerCol.setVisible(hasOwner);
} else if (!hasOwner) {
ownerCol.setVisible(false);
}
}
}

View file

@ -31,6 +31,10 @@ public class BrowserFileOpener {
}
var info = (FileInfo.Unix) file.getInfo();
if (info.getPermissions() == null) {
return fileSystem.openOutput(file.getPath(), totalBytes);
}
var zero = Integer.valueOf(0);
var otherWrite = info.getPermissions().charAt(7) == 'w';
var requiresRoot = zero.equals(info.getUid()) && zero.equals(info.getGid()) && !otherWrite;

View file

@ -41,6 +41,10 @@ public final class BrowserFileSystemHistory {
}
public void updateCurrent(FilePath s) {
if (s == null) {
return;
}
var lastString = getCurrent();
if (cursor.get() != -1 && Objects.equals(lastString, s)) {
return;

View file

@ -1 +1 @@
16.0-6
16.0-7