mro68 opened a new pull request, #7058:
URL: https://github.com/apache/opendal/pull/7058

   ## Problem
   
   The Google Drive backend returns `size=0` for all files during `list()` 
operations, while `stat()` correctly returns file sizes. This causes issues 
with applications like rustic that rely on accurate file metadata from list 
operations.
   
   **Root Cause:**
   
   1. The `gdrive_list()` API call doesn't request `size` and `modifiedTime` 
fields from Google Drive API
   2. The lister doesn't map these fields to the `Metadata` object (even though 
the `GdriveFile` struct already has these fields)
   
   **Impact:**
   
   - Tools like `rustic check` fail with: "size computed by index: X, actual 
size: 0"
   - File size information is unavailable when listing directories
   - Inconsistent behavior between `stat()` and `list()` operations
   
   ## Solution
   
   This PR fixes the issue by:
   
   1. **Adding `fields` parameter to the API call** in `gdrive_list()`:
   
      ```rust
      url = url.push("fields", 
"nextPageToken,files(id,name,mimeType,size,modifiedTime)");
      ```
   
   2. **Mapping metadata fields in the lister** (matching the working `stat()` 
implementation):
      ```rust
      let mut metadata = 
Metadata::new(file_type).with_content_type(file.mime_type.clone());
      if let Some(size) = file.size {
          metadata = metadata.with_content_length(size.parse::<u64>()?);
      }
      if let Some(modified_time) = file.modified_time {
          metadata = 
metadata.with_last_modified(modified_time.parse::<Timestamp>()?);
      }
      ```
   
   ## Testing
   
   - ✅ `cargo clippy --all-targets --features services-gdrive -- -D warnings` 
passes
   - ✅ `cargo fmt --check` passes
   - The fix mirrors the working implementation in `backend.rs` `stat()` method
   
   ## Related Issues
   
   - Related to #6683 (if exists - Google Drive improvements)
   - Related to #6684 (if exists - Google Drive behavior tests)
   
   ## Checklist
   
   - [x] Code follows Apache OpenDAL commit conventions
   - [x] Changes are minimal and focused on the bug fix
   - [x] Implementation matches existing patterns in the codebase
   - [x] No breaking changes to public API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to