bug(services/fs): deleting "/" removes the configured root directory

Đang mở Phù hợp với người mới
#9,635 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@xgbtxy đang làm issue này rồi.

Từ ngày 4/12/2026.

  • #9637 của @xgbtxy — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
81/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu tại core/services/fs/src/deleter.rs, ở FsDeleter::delete_once, và kiểm tra cách root_join phân giải / trước khi xóa khỏi hệ thống tệp. Tái hiện cả hai trường hợp trong issue: xóa không đệ quy trên các thư mục gốc trống và có nội dung, và xóa đệ quy sau khi ghi một tệp. Hoàn thành khi thao tác xóa thư mục gốc không đệ quy giữ nguyên thư mục gốc, còn thao tác xóa đệ quy xóa nội dung bên trong nhưng vẫn giữ thư mục gốc.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug

In core/services/fs/src/deleter.rs, FsDeleter::delete_once resolves path via self.core.root_join(&path)? and removes the resulting path directly without checking whether it resolves to self.core.root:

  1. op.delete("/") (non-recursive) on an empty root runs tokio::fs::remove_dir(&self.core.root), removing the configured root directory itself from disk (and failing with a directory-not-empty error on a populated root instead of keeping non-recursive root deletion as a safe no-op).
  2. op.delete_with("/").recursive(true) (and op.remove_all("/")) runs tokio::fs::remove_dir_all(&self.core.root), deleting the configured root directory itself rather than clearing its children.
Steps to Reproduce
let temp_dir = tempfile::tempdir().unwrap();
let root = temp_dir.path().join("root");
let op = Operator::new(Fs::default().root(root.to_str().unwrap())).unwrap();

op.delete("/").await.unwrap();
assert!(root.is_dir()); // fails: configured root directory was removed

let op = Operator::new(Fs::default().root(root.to_str().unwrap())).unwrap();
op.write("file.txt", "hello").await.unwrap();
op.delete_with("/").recursive(true).await.unwrap();
assert!(root.is_dir()); // fails: configured root directory was removed
Expected Behavior

Matching root-preservation semantics (see #9630):

  • Non-recursive delete("/") should be a safe no-op that preserves both empty and populated configured roots.
  • Recursive delete_with("/").recursive(true) should clear all children inside the configured root (unlinking symlinks without touching external targets) while preserving the configured root directory itself.
AI Usage Statement
  • Harness: Antigravity
  • Model: Gemini 3.1 Pro
  • Effort: High
  • Role: Identified the missing root guard in FsDeleter::delete_once, reproduced both non-recursive and recursive root deletion failures locally, and drafted this report.
Ngôn ngữ chính
Rust
Star
5.5k
Fork
869
Merge trung bình
8 giờ 2 phút
Pull request đã merge (30 ngày)
862

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/opendal

Tất cả issue của apache/opendal

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.