[Core] Add FlashTransfer Logic, Fix Aot and mac sending image issue#58
[Core] Add FlashTransfer Logic, Fix Aot and mac sending image issue#58Lilyltt wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds FlashTransfer upload logic as an alternative to Highway upload for AOT (Ahead-of-Time) compiled environments and macOS platforms, while fixing image sending issues on these platforms.
- Implements FlashTransfer upload mechanism with chunked file uploading
- Adds platform-specific logic to choose between Highway and FlashTransfer upload methods
- Creates supporting protobuf message structures for FlashTransfer communication
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Lagrange.Core/Message/Entities/ImageEntity.cs | Adds platform detection to conditionally use FlashTransfer or Highway upload |
| Lagrange.Core/Internal/Packets/Service/FlashTransferUploadResp.cs | Defines response structure for FlashTransfer upload operations |
| Lagrange.Core/Internal/Packets/Service/FlashTransferUploadReq.cs | Defines request structures for FlashTransfer upload with chunking support |
| Lagrange.Core/Internal/Context/FlashTransferContext.cs | Implements the complete FlashTransfer upload logic with chunked file handling |
| Lagrange.Core/BotContext.cs | Integrates FlashTransferContext into the bot context |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } | ||
| } | ||
|
|
||
| // cnm闹禅tx为什么不能并发,回答我 |
There was a problem hiding this comment.
The comment contains inappropriate language and should be replaced with a professional technical comment explaining why sequential processing is required instead of concurrent uploads.
| // cnm闹禅tx为什么不能并发,回答我 | |
| // Sequential processing is required because the server expects chunks to be uploaded in order. Concurrent uploads may cause data integrity issues or protocol violations. |
| if (RuntimeFeature.IsDynamicCodeCompiled || !RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | ||
| { | ||
| await context.HighwayContext.UploadFile(Stream.Value, message.IsGroup() ? 1004 : 1003, ProtoHelper.Serialize(result.Ext)); | ||
| } | ||
| else | ||
| { | ||
| await context.FlashTransferContext.UploadFile(result.Ext.UKey, Stream.Value); |
There was a problem hiding this comment.
The condition logic appears inverted. It should check for AOT compilation (!IsDynamicCodeCompiled) OR macOS platform to use FlashTransfer, not the opposite.
| if (RuntimeFeature.IsDynamicCodeCompiled || !RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | |
| { | |
| await context.HighwayContext.UploadFile(Stream.Value, message.IsGroup() ? 1004 : 1003, ProtoHelper.Serialize(result.Ext)); | |
| } | |
| else | |
| { | |
| await context.FlashTransferContext.UploadFile(result.Ext.UKey, Stream.Value); | |
| if (!RuntimeFeature.IsDynamicCodeCompiled || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | |
| { | |
| await context.FlashTransferContext.UploadFile(result.Ext.UKey, Stream.Value); | |
| } | |
| else | |
| { | |
| await context.HighwayContext.UploadFile(Stream.Value, message.IsGroup() ? 1004 : 1003, ProtoHelper.Serialize(result.Ext)); |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: sisi0318 <sisi0318@users.noreply.github.com
No description provided.