core icon indicating copy to clipboard operation
core copied to clipboard

fix: drop file fail on windows

Open SodaACE opened this issue 4 months ago • 4 comments

Types

  • [ ] 🎉 New Features
  • [x] 🐛 Bug Fixes
  • [ ] 📚 Documentation Changes
  • [ ] 💄 Code Style Changes
  • [ ] 💄 Style Changes
  • [ ] 🪚 Refactors
  • [ ] 🚀 Performance Improvements
  • [ ] 🏗️ Build System
  • [ ] ⏱ Tests
  • [ ] 🧹 Chores
  • [ ] Other Changes

Background or solution

fix https://github.com/opensumi/core/issues/3615 f04a64cec0c1c8e0a6ac2216e36b19bd 在 $ensureFileExis方法里的targetPath原来类似于图片上这种,在创建文件写入流会报错,报错原因是路径生成错误。

Changelog

修复在windows上,拖拽文件到IDE中,文件损坏的问题

Summary by CodeRabbit

  • Bug Fixes
    • 修复文件拖放时的目标路径解析问题,解决在 Windows 等平台因路径格式不兼容导致无法创建/写入文件的情况,提升稳定性与跨平台兼容性。

SodaACE avatar Aug 22 '25 08:08 SodaACE

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 22 '25 08:08 CLAassistant

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


lintao4 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Aug 22 '25 08:08 CLAassistant

Walkthrough

在 FileDropService 中,将两个内部目标路径的计算从 Uri.file(...).path 切换为 Uri.file(...).fsPath,其余写入流创建、写入与关闭逻辑未改动;无公开 API 变更。

Changes

Cohort / File(s) Summary
文件拖拽服务路径计算更新
packages/addons/src/node/file-drop.service.ts
在 $ensureFileExist 与 $writeStream 中,将目标路径从 .path 改为 .fsPath,用于生成本地文件系统路径;其余逻辑(创建/缓存 WriteStream、按 'binary' 写入、完成时关闭与移除)保持不变。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
修复从操作系统文件管理器拖拽到文件树后文件内容丢失的问题(#3615) 仅更换为 fsPath 涉及路径规范化,疑似面向 Windows,但缺少验证与测试覆盖,无法确认是否完全解决所有场景。

[!TIP]

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Aug 22 '25 08:08 coderabbitai[bot]

Codecov Report

:x: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 52.61%. Comparing base (7dfa870) to head (8a11e83).

Files with missing lines Patch % Lines
packages/addons/src/node/file-drop.service.ts 0.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4624      +/-   ##
==========================================
+ Coverage   52.59%   52.61%   +0.01%     
==========================================
  Files        1686     1686              
  Lines      104362   104362              
  Branches    22682    22682              
==========================================
+ Hits        54894    54905      +11     
+ Misses      41097    41087      -10     
+ Partials     8371     8370       -1     
Flag Coverage Δ
jsdom 48.14% <0.00%> (+<0.01%) :arrow_up:
node 12.03% <0.00%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Aug 22 '25 12:08 codecov[bot]