-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(drivers/mediafire): support concurrent upload #1387
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d68b1da
feat(drivers): add MediaFire driver with concurrent upload support
Da3zKi7 06abed9
feat(drivers): add MediaFire driver with concurrent upload support
Da3zKi7 7beeb51
feat(stream): add DiscardSection method to StreamSectionReader for sk…
j2rong4cn 9b33d93
feat(mediafire): refactor resumableUpload logic for improved upload h…
j2rong4cn c3031e1
fix(mediafire): stop cron job and clear action token in Drop method
j2rong4cn 94bc043
.
j2rong4cn 0b24556
Merge branch 'mediafire' into feat/mediafire
j2rong4cn 21c6ea9
fix(mediafire): optimize buffer sizing logic in uploadUnits method
j2rong4cn e756a67
fix(docs): remove duplicate MediaFire
j2rong4cn 7081986
fix(mediafire): revert 'optimization', large files should not be full…
Da3zKi7 4b7f41f
Merge branch 'mediafire' into Da3zKi7-feat/mediafire
ILoveScratch2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,11 +9,15 @@ D@' 3z K!7 - The King Of Cracking | |||||
|
|
||||||
| Modifications by ILoveScratch2<ilovescratch@foxmail.com> | ||||||
| Date: 2025-09-21 | ||||||
|
|
||||||
| Date: 2025-09-26 | ||||||
| Final opts by @Suyunjing @j2rong4cn @KirCute @Da3zKi7 | ||||||
| */ | ||||||
|
|
||||||
| import ( | ||||||
| "context" | ||||||
| "fmt" | ||||||
| "math/rand" | ||||||
| "net/http" | ||||||
| "strconv" | ||||||
| "time" | ||||||
|
|
@@ -22,6 +26,7 @@ import ( | |||||
| "github.com/OpenListTeam/OpenList/v4/internal/driver" | ||||||
| "github.com/OpenListTeam/OpenList/v4/internal/model" | ||||||
| "github.com/OpenListTeam/OpenList/v4/internal/stream" | ||||||
| "github.com/OpenListTeam/OpenList/v4/pkg/cron" | ||||||
| "github.com/OpenListTeam/OpenList/v4/pkg/utils" | ||||||
| "golang.org/x/time/rate" | ||||||
| ) | ||||||
|
|
@@ -30,6 +35,8 @@ type Mediafire struct { | |||||
| model.Storage | ||||||
| Addition | ||||||
|
|
||||||
| cron *cron.Cron | ||||||
|
|
||||||
| actionToken string | ||||||
| limiter *rate.Limiter | ||||||
|
|
||||||
|
|
@@ -66,7 +73,18 @@ func (d *Mediafire) Init(ctx context.Context) error { | |||||
| } | ||||||
| // Validate and refresh session token if needed | ||||||
| if _, err := d.getSessionToken(ctx); err != nil { | ||||||
| return d.renewToken(ctx) | ||||||
|
|
||||||
| d.renewToken(ctx) | ||||||
|
|
||||||
| // Avoids 10 mins token expiry (6- 9) | ||||||
| num := rand.Intn(4) + 6 | ||||||
|
|
||||||
| d.cron = cron.NewCron(time.Minute * time.Duration(num)) | ||||||
| d.cron.Do(func() { | ||||||
| // Crazy, but working way to refresh session token | ||||||
| d.renewToken(ctx) | ||||||
|
||||||
| d.renewToken(ctx) | |
| d.renewToken(context.Background()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error returned by
d.renewToken(ctx)is ignored. If token renewal fails, the Init method should return the error instead of continuing execution.