Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map unrecognized file types to 'WeirdFile' instead of throwing. #370

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ enum UnixFileType
BlockDevice,
Socket,
Fifo,
WeirdFile
}
[Flags]
enum UnixFileTypeFilter
Expand All @@ -505,6 +506,7 @@ enum UnixFileTypeFilter
BlockDevice,
Socket,
Fifo,
WeirdFile
}
[Flags]
enum UnixFilePermissions // values match System.IO.UnixFileMode.
Expand Down
2 changes: 1 addition & 1 deletion src/Tmds.Ssh/SftpChannel.Reader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public PacketType ReadPacketType()
UnixFileTypeByte.BlockDevice => UnixFileType.BlockDevice,
UnixFileTypeByte.Socket => UnixFileType.Socket,
UnixFileTypeByte.Fifo => UnixFileType.Fifo,
_ => throw new InvalidDataException($"Invalid mode: {mode}.")
_ => UnixFileType.WeirdFile
};
return (permissions, fileType);
}
Expand Down
1 change: 1 addition & 0 deletions src/Tmds.Ssh/UnixFileType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public enum UnixFileType : short
BlockDevice = UnixFileTypeFilter.BlockDevice << UnixFileTypeFilterExtensions.TypeShift | UnixFileTypeByte.BlockDevice,
Socket = UnixFileTypeFilter.Socket << UnixFileTypeFilterExtensions.TypeShift | UnixFileTypeByte.Socket,
Fifo = UnixFileTypeFilter.Fifo << UnixFileTypeFilterExtensions.TypeShift | UnixFileTypeByte.Fifo,
WeirdFile = unchecked((short)(UnixFileTypeFilter.WeirdFile << UnixFileTypeFilterExtensions.TypeShift))
}

static class UnixFileTypeExtensions
Expand Down
1 change: 1 addition & 0 deletions src/Tmds.Ssh/UnixFileTypeFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum UnixFileTypeFilter : byte
BlockDevice = 16,
Socket = 32,
Fifo = 64,
WeirdFile = 128
}

static class UnixFileTypeFilterExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ namespace Tmds.Ssh
BlockDevice = 4102,
Socket = 8204,
Fifo = 16385,
WeirdFile = -32768,
}
[System.Flags]
public enum UnixFileTypeFilter : byte
Expand All @@ -581,6 +582,7 @@ namespace Tmds.Ssh
BlockDevice = 16,
Socket = 32,
Fifo = 64,
WeirdFile = 128,
}
public sealed class UploadEntriesOptions
{
Expand Down