feat: backend-based file and directory duplication#9142
feat: backend-based file and directory duplication#9142Light2Dark merged 5 commits intomarimo-team:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
b8a2f74 to
0c68692
Compare
Bundle ReportChanges will increase total bundle size by 2.66kB (0.01%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: marimo-esmAssets Changed:
Files in
Files in
Files in
|
There was a problem hiding this comment.
Pull request overview
Implements a server-side file/directory duplication feature, exposing it via a new /api/files/copy endpoint and wiring it through the frontend file tree (including WASM/Pyodide) to avoid “download then upload” duplication for large files.
Changes:
- Added backend filesystem + API support for copying files/directories (
OSFileSystem.copy_file_or_directory,/api/files/copy). - Updated frontend request layer + file tree state to invoke backend copy and sync tree state.
- Extended OpenAPI/WASM bridge types and added tests across backend, frontend, and Pyodide.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/_server/files/test_os_file_system.py | Adds unit tests for unique-path generation helper used by filesystem operations. |
| tests/_server/api/endpoints/test_file_explorer.py | Adds API integration tests for the new copy endpoint for both files and directories. |
| tests/_pyodide/test_pyodide_session.py | Adds a Pyodide bridge test covering the new copy behavior. |
| packages/openapi/src/api.ts | Adds generated OpenAPI client typings for /api/files/copy and copy request/response schemas. |
| packages/openapi/api.yaml | Adds OpenAPI schema + path definition for /api/files/copy. |
| marimo/_server/models/files.py | Introduces FileCopyRequest/FileCopyResponse models. |
| marimo/_server/files/os_file_system.py | Implements copy_file_or_directory and factors unique-name logic into _generate_unique_path. |
| marimo/_server/files/file_system.py | Extends the filesystem abstract interface with copy_file_or_directory. |
| marimo/_server/api/endpoints/file_explorer.py | Adds /copy endpoint under the file explorer API router. |
| marimo/_pyodide/pyodide_session.py | Exposes copy via the Pyodide session bridge. |
| marimo/_cli/development/commands.py | Includes new copy request/response models in API schema generation. |
| frontend/src/core/wasm/worker/worker.ts | Ensures copy operations are treated as requiring sync in the worker. |
| frontend/src/core/wasm/worker/types.ts | Adds copy_file_or_directory to the RawBridge interface. |
| frontend/src/core/wasm/bridge.ts | Adds sendCopyFileOrFolder implementation to the Pyodide bridge. |
| frontend/src/core/network/types.ts | Exposes FileCopyRequest/FileCopyResponse types and adds copy to EditRequests. |
| frontend/src/core/network/requests-toasting.tsx | Adds default error toast text for copy requests. |
| frontend/src/core/network/requests-static.ts | Adds static (non-edit-mode) stub for copy requests. |
| frontend/src/core/network/requests-network.ts | Adds network request implementation for /api/files/copy. |
| frontend/src/core/network/requests-lazy.ts | Adds lazy-request action mapping for copy requests. |
| frontend/src/core/islands/bridge.ts | Adds copy request stub for islands bridge. |
| frontend/src/components/editor/file-tree/state.tsx | Wires copy request into RequestingTree construction. |
| frontend/src/components/editor/file-tree/requesting-tree.tsx | Adds copy() method to perform copy + update tree state. |
| frontend/src/components/editor/file-tree/file-explorer.tsx | Switches duplicate action to use backend copy via RequestingTree.copy. |
| frontend/src/components/editor/file-tree/tests/requesting-tree.test.ts | Adds unit tests for RequestingTree.copy and error handling. |
| frontend/src/mocks/requests.ts | Updates mocked request client with sendCopyFileOrFolder. |
- Introduce /api/files/copy endpoint in file_explorer.py for session-independent duplication. - Add copy_file_or_directory to FileSystem and implement it in OSFileSystem using shutil.copy2 and shutil.copytree. - Refactor OSFileSystem to use standalone copy, delete, and check_new_path helpers, ensuring consistency between copy and move operations. - Enhance file explorer tests with comprehensive copy scenarios and robust move verification. - Fix logging typo in move endpoint. fix: register FileCopy models in OpenAPI schema This fixes the fe-codegen error by including FileCopyRequest and FileCopyResponse in the OpenAPI schema generation list. feat: implement file and folder copy functionality across the application feat: implement file and directory copy functionality with unique naming feat: add copy functionality for files and directories in tests and UI
for more information, see https://pre-commit.ci
…frontend error handling
7825c22 to
fa3b0f5
Compare
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.2-dev42 |
📝 Summary
Closes #9059
Implements a native server-side file and directory duplication feature. This addresses performance issues with large files and enables workspace-wide duplication independent of active notebook sessions.
This PR implements the functionality required for Issue #6877.
Changes
OSFileSystem):copy_file_or_directorymethod usingshutilfor server-side operations./api/files/copyendpoint infile_explorer.py.sendCopyFileOrFoldernetwork request.RequestingTreeto handle duplication and tree state synchronization.PyodideBridgeto support the new duplication functionality.Testing
_generate_unique_pathintests/_server/files/test_os_file_system.py. Added API integration tests intests/_server/api/endpoints/test_file_explorer.py.RequestingTree.copyinfrontend/src/components/editor/file-tree/__tests__/requesting-tree.test.ts.tests/_pyodide/test_pyodide_session.py.📋 Pre-Review Checklist
✅ Merge Checklist