Skip to content

支持GoogleDrive#490

Merged
CodFrm merged 7 commits intomainfrom
develop/google-drive
Jul 5, 2025
Merged

支持GoogleDrive#490
CodFrm merged 7 commits intomainfrom
develop/google-drive

Conversation

@CodFrm
Copy link
Copy Markdown
Member

@CodFrm CodFrm commented Jul 5, 2025

No description provided.

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member Author

@CodFrm CodFrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应用github copilot建议

CodFrm and others added 2 commits July 5, 2025 18:11
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Remove unused size() and md5() methods
- Remove unused findFile() private method
- Remove unused imports (calculateMd5, MD5)
@CodFrm CodFrm requested a review from Copilot July 5, 2025 10:14

This comment was marked as outdated.

@CodFrm CodFrm requested a review from Copilot July 5, 2025 10:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for Google Drive as a new filesystem option, integrating it into the UI, authentication, and core filesystem factory.

  • Introduce GoogleDriveFileSystem, GoogleDriveFileReader, and GoogleDriveFileWriter.
  • Register “googledrive” in the filesystem selector and factory.
  • Update backup-tools logic to handle empty lists without early return.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/pages/options/routes/Tools.tsx Change empty-list handling to an if/else instead of early return
src/pages/components/FileSystemParams/index.tsx Add Google Drive entry to filesystem parameters
packages/filesystem/googledrive/rw.ts Implement read/write classes for Google Drive
packages/filesystem/googledrive/googledrive.ts Full Google Drive filesystem implementation
packages/filesystem/factory.ts Register “googledrive” type and factory case
packages/filesystem/auth.ts Extend NetDiskType to include “googledrive”
Comments suppressed due to low confidence (1)

packages/filesystem/googledrive/googledrive.ts:107

  • [nitpick] The parameter name nothen is unclear; consider renaming it to something more descriptive like rawResponse or returnRawResponse for readability.
  request(url: string, config?: RequestInit, nothen?: boolean) {

@@ -162,9 +162,9 @@ function Tools() {
list = list.filter((file) => file.name.endsWith(".zip"));
if (list.length === 0) {
Message.info(t("no_backup_files")!);
Copy link

Copilot AI Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the early return changes control flow: after showing the info message, the function will continue instead of exiting. Consider re-adding a return or explicitly handling the post-empty-list logic to avoid unintended side effects.

Suggested change
Message.info(t("no_backup_files")!);
Message.info(t("no_backup_files")!);
return;

Copilot uses AI. Check for mistakes.
},
{
key: "googledrive",
name: "Google Drive",
Copy link

Copilot AI Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The display name "Google Drive" is hardcoded; consider using a translation function (e.g. t('google_drive')) to keep it consistent with other localized strings.

Suggested change
name: "Google Drive",
name: t("google_drive"),

Copilot uses AI. Check for mistakes.
const data = await this.fs.request(`https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`, {}, true);

if (data.status !== 200) {
return Promise.reject(await data.text());
Copy link

Copilot AI Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rejecting with a raw string can make downstream error handling inconsistent; wrap the message in an Error object (e.g. Promise.reject(new Error(await data.text()))).

Suggested change
return Promise.reject(await data.text());
return Promise.reject(new Error(await data.text()));

Copilot uses AI. Check for mistakes.
@CodFrm CodFrm merged commit dc38f7f into main Jul 5, 2025
3 checks passed
@CodFrm CodFrm deleted the develop/google-drive branch July 8, 2025 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]支持GoogleDrive 可以支持Google 同步码类似Tampermonkey 的浏览器同步

2 participants