Skip to content

fix(runner): use shutil.move for cross-disk write on Windows#1483

Merged
xieyxclack merged 1 commit intoagentscope-ai:mainfrom
Leirunlin:fix/windows-shutil-move
Mar 14, 2026
Merged

fix(runner): use shutil.move for cross-disk write on Windows#1483
xieyxclack merged 1 commit intoagentscope-ai:mainfrom
Leirunlin:fix/windows-shutil-move

Conversation

@Leirunlin
Copy link
Copy Markdown
Collaborator

Description

Use shutil.move to handle cross-disk write on Windows

Related Issue: Fixes #1431

Security Considerations: N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactoring

Component(s) Affected

  • Core / Backend (app, agents, config, providers, utils, local_models)
  • Console (frontend web UI)
  • Channels (DingTalk, Feishu, QQ, Discord, iMessage, etc.)
  • Skills
  • CLI
  • Documentation (website)
  • Tests
  • CI/CD
  • Scripts / Deploy

Checklist

  • I ran pre-commit run --all-files locally and it passes
  • If pre-commit auto-fixed files, I committed those changes and reran checks
  • I ran tests locally (pytest or as relevant) and they pass
  • Documentation updated (if needed)
  • Ready for review

@Leirunlin Leirunlin temporarily deployed to maintainer-approved March 14, 2026 07:08 — with GitHub Actions Inactive
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug affecting file operations on Windows, specifically when temporary files need to be moved to their final destination across different disk partitions. By adopting shutil.move(), the change ensures reliable and atomic file replacement, preventing potential data loss or corruption in these specific environments.

Highlights

  • Bug Fix: Cross-Disk File Operations on Windows: Resolved an issue where atomic file replacement using Path.replace() could fail on Windows when attempting to move files across different disk drives. The fix involves switching to shutil.move() which correctly handles such scenarios.
  • Improved File Handling: The json_repo.py files in both the crons and runner modules now utilize shutil.move() for atomic file saving, enhancing robustness, especially on Windows systems.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/copaw/app/crons/repo/json_repo.py
    • Imported the shutil module.
    • Replaced tmp_path.replace(self._path) with shutil.move(str(tmp_path), str(self._path)) for atomic file saving.
  • src/copaw/app/runner/repo/json_repo.py
    • Imported the shutil module.
    • Replaced tmp_path.replace(self._path) with shutil.move(str(tmp_path), str(self._path)) for atomic file saving.
    • Updated the comment regarding atomic replace to explicitly mention shutil.move's handling of cross-disk operations on Windows.
Activity
  • The pull request was created by Leirunlin.
  • The author marked the PR as a bug fix affecting the Core / Backend component.
  • The author confirmed local pre-commit checks passed and tests passed.
  • The PR is marked as ready for review.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses a cross-disk file move issue on Windows by replacing pathlib.Path.replace with shutil.move. The change is applied to two similar repository implementations. My review includes a couple of suggestions to improve code clarity and consistency. Specifically, I've recommended removing redundant str() conversions since shutil.move supports pathlib.Path objects in modern Python versions. I've also suggested adding a comment in one of the files to ensure explanatory comments are consistent across both modified files. These changes will make the code cleaner and more maintainable.

Comment thread src/copaw/app/crons/repo/json_repo.py
Comment thread src/copaw/app/runner/repo/json_repo.py
Copy link
Copy Markdown
Member

@xieyxclack xieyxclack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xieyxclack xieyxclack merged commit 0baf6b6 into agentscope-ai:main Mar 14, 2026
20 checks passed
@Leirunlin Leirunlin deleted the fix/windows-shutil-move branch April 1, 2026 03:38
tudan110 pushed a commit to tudan110/QwenPaw that referenced this pull request Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants