diff --git a/src/FubarDev.FtpServer.FileSystem.Unix/UnixFileSystemEntry.cs b/src/FubarDev.FtpServer.FileSystem.Unix/UnixFileSystemEntry.cs index c7ed99a6..af8808a2 100644 --- a/src/FubarDev.FtpServer.FileSystem.Unix/UnixFileSystemEntry.cs +++ b/src/FubarDev.FtpServer.FileSystem.Unix/UnixFileSystemEntry.cs @@ -3,6 +3,7 @@ // using System; +using System.Globalization; using JetBrains.Annotations; @@ -20,6 +21,8 @@ protected UnixFileSystemEntry( { GenericInfo = _info = info; Permissions = new UnixPermissions(info); + Owner = GetNameOrId(() => info.OwnerUser.UserName, () => info.OwnerUserId); + Group = GetNameOrId(() => info.OwnerGroup.GroupName, () => info.OwnerGroupId); } /// @@ -29,10 +32,10 @@ protected UnixFileSystemEntry( public UnixFileSystemInfo GenericInfo { get; } /// - public string Owner => _info.OwnerUser.UserName; + public string Owner { get; } /// - public string Group => _info.OwnerGroup.GroupName; + public string Group { get; } /// public string Name => _info.Name; @@ -48,5 +51,17 @@ protected UnixFileSystemEntry( /// public long NumberOfLinks => _info.LinkCount; + + private static string GetNameOrId(Func getName, Func getId) + { + try + { + return getName(); + } + catch + { + return getId().ToString(CultureInfo.InvariantCulture); + } + } } }