Skip to content
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
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tower-http = { version = "0.6.2", features = ["cors", "trace"] }
indexmap = { version = "2.8.0", features = ["serde"] }
blake2 = "0.10.6"
pgvector = { version = "0.4.0", features = ["sqlx"] }
phf = { version = "0.11.3", features = ["macros"] }
indenter = "0.3.3"
itertools = "0.14.0"
derivative = "2.2.0"
Expand Down
77 changes: 31 additions & 46 deletions src/ops/sources/google_drive.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use chrono::Duration;
use google_drive3::{
api::{File, Scope},
yup_oauth2::{read_service_account_key, ServiceAccountAuthenticator},
DriveHub,
api::{File, Scope},
yup_oauth2::{ServiceAccountAuthenticator, read_service_account_key},
};
use http_body_util::BodyExt;
use hyper_rustls::HttpsConnector;
use hyper_util::client::legacy::connect::HttpConnector;
use phf::phf_map;

use crate::base::field_attrs;
use crate::ops::sdk::*;
Expand All @@ -18,45 +19,33 @@ struct ExportMimeType {

const FOLDER_MIME_TYPE: &str = "application/vnd.google-apps.folder";
const FILE_MIME_TYPE: &str = "application/vnd.google-apps.file";
static EXPORT_MIME_TYPES: LazyLock<HashMap<&'static str, ExportMimeType>> = LazyLock::new(|| {
HashMap::from([
(
"application/vnd.google-apps.document",
ExportMimeType {
text: "text/markdown",
binary: "application/pdf",
},
),
(
"application/vnd.google-apps.spreadsheet",
ExportMimeType {
text: "text/csv",
binary: "application/pdf",
},
),
(
"application/vnd.google-apps.presentation",
ExportMimeType {
text: "text/plain",
binary: "application/pdf",
},
),
(
"application/vnd.google-apps.drawing",
ExportMimeType {
text: "image/svg+xml",
binary: "image/png",
},
),
(
"application/vnd.google-apps.script",
ExportMimeType {
text: "application/vnd.google-apps.script+json",
binary: "application/vnd.google-apps.script+json",
},
),
])
});
static EXPORT_MIME_TYPES: phf::Map<&'static str, ExportMimeType> = phf_map! {
"application/vnd.google-apps.document" =>
ExportMimeType {
text: "text/markdown",
binary: "application/pdf",
},
"application/vnd.google-apps.spreadsheet" =>
ExportMimeType {
text: "text/csv",
binary: "application/pdf",
},
"application/vnd.google-apps.presentation" =>
ExportMimeType {
text: "text/plain",
binary: "application/pdf",
},
"application/vnd.google-apps.drawing" =>
ExportMimeType {
text: "image/svg+xml",
binary: "image/png",
},
"application/vnd.google-apps.script" =>
ExportMimeType {
text: "application/vnd.google-apps.script+json",
binary: "application/vnd.google-apps.script+json",
},
};

fn is_supported_file_type(mime_type: &str) -> bool {
!mime_type.starts_with("application/vnd.google-apps.")
Expand Down Expand Up @@ -291,11 +280,7 @@ impl<T> ResultExt<T> for google_drive3::Result<T> {
}

fn optional_modified_time(include_ordinal: bool) -> &'static str {
if include_ordinal {
",modifiedTime"
} else {
""
}
if include_ordinal { ",modifiedTime" } else { "" }
}

#[async_trait]
Expand Down