Normalized Id across all files and moved mimetypes into a shared place

This commit is contained in:
Kenneth Skovhede
2026-02-11 16:23:35 +01:00
parent ce8c1aab7f
commit 5eb80854ae
48 changed files with 157 additions and 91 deletions
@@ -14,9 +14,9 @@ internal class DriveFileContentSourceEntry(SourceProvider provider, string paren
{
var service = provider.ApiHelper.GetDriveService();
if (IsGoogleDoc(file.MimeType))
if (GoogleMimeTypes.IsGoogleDoc(file.MimeType))
{
var exportMimeType = GetExportMimeType(file.MimeType);
var exportMimeType = GoogleMimeTypes.GetExportMimeType(file.MimeType);
var request = service.Files.Export(file.Id, exportMimeType);
var stream = new MemoryStream();
await request.DownloadAsync(stream, cancellationToken);
@@ -33,25 +33,6 @@ internal class DriveFileContentSourceEntry(SourceProvider provider, string paren
}
}
private static bool IsGoogleDoc(string mimeType)
{
return mimeType.StartsWith("application/vnd.google-apps.") &&
mimeType != "application/vnd.google-apps.folder" &&
mimeType != "application/vnd.google-apps.shortcut";
}
private static string GetExportMimeType(string mimeType)
{
return mimeType switch
{
"application/vnd.google-apps.document" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.google-apps.spreadsheet" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.google-apps.presentation" => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"application/vnd.google-apps.script" => "application/vnd.google-apps.script+json",
_ => "application/pdf"
};
}
public override Task<Dictionary<string, string?>> GetMinorMetadata(CancellationToken cancellationToken)
{
return Task.FromResult(new Dictionary<string, string?>
@@ -59,7 +40,7 @@ internal class DriveFileContentSourceEntry(SourceProvider provider, string paren
{ "gsuite:v", "1" },
{ "gsuite:Type", SourceItemType.DriveFileContent.ToString() },
{ "gsuite:Name", "content" },
{ "gsuite:id", file.Id },
{ "gsuite:Id", file.Id },
{ "gsuite:MimeType", file.MimeType }
}
.Where(kv => !string.IsNullOrEmpty(kv.Value))