Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(services/gdrive): skip the trailing slash when creating and querying the directory #5631

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/raw/path_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub trait PathQuery {
///
/// OpenDAL is designed for path based storage systems, such as S3, HDFS, etc. But there are many
/// services that are not path based, such as OneDrive, Google Drive, etc. For these services, we
/// lookup files based on id. The lookup of id is very expensive, so we cache the path to id mapping
/// look up files based on id. The lookup of id is very expensive, so we cache the path to id mapping
/// in PathCacher.
///
/// # Behavior
Expand Down
7 changes: 5 additions & 2 deletions core/src/services/gdrive/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,10 @@ impl PathQuery for GdrivePathQuery {
// Make sure name has been replaced with escaped name.
//
// ref: <https://developers.google.com/drive/api/guides/ref-search-terms>
format!("name = '{}'", name.replace('\'', "\\'")),
format!(
"name = '{}'",
name.replace('\'', "\\'").trim_end_matches('/')
),
format!("'{}' in parents", parent_id),
"trashed = false".to_string(),
];
Expand Down Expand Up @@ -397,7 +400,7 @@ impl PathQuery for GdrivePathQuery {
let url = "https://www.googleapis.com/drive/v3/files";

let content = serde_json::to_vec(&json!({
"name": name,
"name": name.trim_end_matches('/'),
"mimeType": "application/vnd.google-apps.folder",
// If the parent is not provided, the folder will be created in the root folder.
"parents": [parent_id],
Expand Down
Loading