From 3a700643f0152aeb63b769e62b728a39d729c038 Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 28 Aug 2024 23:10:30 +0000 Subject: [PATCH] Fix owner info NPEs --- .../io/xpipe/app/browser/file/BrowserFileListComp.java | 4 ++-- .../java/io/xpipe/app/browser/fs/OpenFileSystemCache.java | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileListComp.java b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileListComp.java index 6d0c27849..45b9ceae4 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileListComp.java +++ b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileListComp.java @@ -189,10 +189,10 @@ public final class BrowserFileListComp extends SimpleComp { var m = fileList.getFileSystemModel(); var user = unix.getUser() != null ? unix.getUser() - : m.getCache().getUsers().get(unix.getUid()); + : m.getCache().getUsers().getOrDefault(unix.getUid(), "?"); var group = unix.getGroup() != null ? unix.getGroup() - : m.getCache().getGroups().get(unix.getGid()); + : m.getCache().getGroups().getOrDefault(unix.getGid(), "?"); var uid = String.valueOf( unix.getUid() != null ? unix.getUid() : m.getCache().getUidForUser(user)); var gid = String.valueOf( diff --git a/app/src/main/java/io/xpipe/app/browser/fs/OpenFileSystemCache.java b/app/src/main/java/io/xpipe/app/browser/fs/OpenFileSystemCache.java index 66ac5a467..d936992cf 100644 --- a/app/src/main/java/io/xpipe/app/browser/fs/OpenFileSystemCache.java +++ b/app/src/main/java/io/xpipe/app/browser/fs/OpenFileSystemCache.java @@ -58,7 +58,9 @@ public class OpenFileSystemCache extends ShellControlCache { .orElse(""); lines.lines().forEach(s -> { var split = s.split(":"); - users.putIfAbsent(Integer.parseInt(split[2]), split[0]); + try { + users.putIfAbsent(Integer.parseInt(split[2]), split[0]); + } catch (NumberFormatException ignored) {} }); if (users.isEmpty()) { @@ -77,7 +79,9 @@ public class OpenFileSystemCache extends ShellControlCache { .orElse(""); lines.lines().forEach(s -> { var split = s.split(":"); - groups.putIfAbsent(Integer.parseInt(split[2]), split[0]); + try { + groups.putIfAbsent(Integer.parseInt(split[2]), split[0]); + } catch (NumberFormatException ignored) {} }); if (groups.isEmpty()) {