erickguan commented on code in PR #6683:
URL: https://github.com/apache/opendal/pull/6683#discussion_r2438495350


##########
core/src/services/gdrive/core.rs:
##########
@@ -468,22 +492,63 @@ pub struct GdriveTokenResponse {
     expires_in: u64,
 }
 
-/// This is the file struct returned by the Google Drive API.
-/// This is a complex struct, but we only add the fields we need.
-/// refer to 
https://developers.google.com/drive/api/reference/rest/v3/files#File
+/// File struct for Google Drive API
+/// We select a few arbitrary fields.
+/// When update fields, keep `DRIVE_FILE_FIELDS` in sync to fetch related data.
+/// Read more 
[here](https://developers.google.com/drive/api/reference/rest/v3/files#File)
 #[derive(Deserialize, Debug)]
 #[serde(rename_all = "camelCase")]
 pub struct GdriveFile {
     pub mime_type: String,
     pub id: String,
     pub name: String,
+    // Size may be null for folders or shortcuts
     pub size: Option<String>,
-    // The modified time is not returned unless the `fields`
-    // query parameter contains `modifiedTime`.
-    // As we only need the modified time when we do `stat` operation,
-    // if other operations(such as search) do not specify the `fields` query 
parameter,
-    // try to access this field, it will be `None`.
-    pub modified_time: Option<String>,
+    pub modified_time: String,
+    // Only applicable to files with binary content in Google Drive.
+    pub md5_checksum: Option<String>,
+    // A short-lived link to the file's version.
+    pub version: Option<String>,
+}
+
+impl GdriveFile {
+    /// Converts Google Drive file metadata to OpenDAL Metadata.
+    ///
+    /// This method parses the Google Drive API response fields and maps them
+    /// to OpenDAL's standard metadata fields.
+    pub(crate) fn to_metadata(&self) -> Result<Metadata> {
+        let mut metadata = Metadata::default();
+
+        let file_type = if self.mime_type == GDRIVE_FOLDER_MIME_TYPE {
+            EntryMode::DIR
+        } else {
+            EntryMode::FILE
+        };
+        metadata.set_mode(file_type);

Review Comment:
   Nitpick: use Metadata::new(file_type)



-- 
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