Skip to content

Conversation

@jerrita
Copy link
Contributor

@jerrita jerrita commented Oct 6, 2025

Description

Add reference support for OneDrive.

Motivation and Context

This feature is useful when you want to share multiple paths on OneDrive without having to log in repeatedly.

How Has This Been Tested?

Tested on my cluster; may require additional testing.

Checklist

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

@xrgzs
Copy link
Member

xrgzs commented Oct 6, 2025

Please give some tests. And does this work after the reference's token refreshed?

@jyxjjj jyxjjj added enhancement invalid Invalid Content/Cannot Reproduce needs-triage Module: Driver Driver-Related Issue/PR labels Oct 6, 2025
@jerrita
Copy link
Contributor Author

jerrita commented Oct 6, 2025

I've run it on my cluster, and it works properly. It should work after the reference token is refreshed, as it will use the reference token for each request.

Some extra tests might be needed, but I'm not familiar with Go, so I'll wait for someone else to pick it up.

@jerrita jerrita marked this pull request as draft October 7, 2025 08:27
@jerrita jerrita force-pushed the feat-onedrive-ref branch from 24cc5d1 to 91b625e Compare October 7, 2025 08:36
@jerrita jerrita marked this pull request as ready for review October 7, 2025 08:39
@xrgzs xrgzs requested a review from Copilot October 7, 2025 09:09
Copy link
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 reference support for OneDrive drivers, allowing multiple OneDrive instances to share authentication tokens without requiring separate login processes. This enables sharing multiple paths on OneDrive efficiently.

Key changes:

  • Added reference field to OneDrive struct to store shared authentication
  • Modified token refresh logic to use reference tokens when available
  • Added InitReference method to establish driver references

Reviewed Changes

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

File Description
drivers/onedrive/driver.go Adds ref field and InitReference method for sharing authentication between OneDrive instances
drivers/onedrive/util.go Updates token refresh and request methods to use reference tokens when available

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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

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


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jerrita jerrita requested a review from Copilot October 7, 2025 12:52
Copy link
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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jerrita jerrita requested a review from Copilot October 7, 2025 12:53
Copy link
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

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


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 76 to 89
d.mutex.Lock()
ref := d.ref
if ref != nil {
err := ref._refreshToken()
if err != nil {
d.mutex.Unlock()
return err
}
d.AccessToken = ref.AccessToken
d.RefreshToken = ref.RefreshToken
d.mutex.Unlock()
return nil
}
d.mutex.Unlock()
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Potential race condition: The reference token refresh and token copying should be protected by both mutexes. Consider acquiring ref.mutex.Lock() before calling ref._refreshToken() to prevent concurrent modifications to the reference's tokens.

Copilot uses AI. Check for mistakes.
@jerrita
Copy link
Contributor Author

jerrita commented Oct 7, 2025

It is not extremely high concurrency; I think the lock just adds complexity and reduces performance.

The initial commit might be sufficient.

@jerrita jerrita force-pushed the feat-onedrive-ref branch from 292c42f to 24cc5d1 Compare October 8, 2025 07:35
@jerrita
Copy link
Contributor Author

jerrita commented Oct 8, 2025

Reverted to the initial commit.

@j2rong4cn j2rong4cn merged commit a109152 into OpenListTeam:main Oct 18, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement invalid Invalid Content/Cannot Reproduce Module: Driver Driver-Related Issue/PR needs-triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants