-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(drivers/alias): default sort & substitute link #1917
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -493,3 +493,43 @@ func (d *Alias) extract(ctx context.Context, reqPath string, args model.ArchiveI | |||||
| link, _, err := op.DriverExtract(ctx, storage, reqActualPath, args) | ||||||
| return link, err | ||||||
| } | ||||||
|
|
||||||
xrgzs marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| func getAllSort(dirs []model.Obj) model.Sort { | ||||||
| ret := model.Sort{} | ||||||
| noSort := false | ||||||
| noExtractFolder := false | ||||||
| for _, dir := range dirs { | ||||||
| if dir == nil { | ||||||
| continue | ||||||
| } | ||||||
| storage, err := fs.GetStorage(dir.GetPath(), &fs.GetStoragesArgs{}) | ||||||
| if err != nil { | ||||||
| continue | ||||||
| } | ||||||
| if !noSort && storage.GetStorage().OrderBy != "" { | ||||||
| if ret.OrderBy == "" { | ||||||
| ret.OrderBy = storage.GetStorage().OrderBy | ||||||
| ret.OrderDirection = storage.GetStorage().OrderDirection | ||||||
| if ret.OrderDirection == "" { | ||||||
| ret.OrderDirection = "asc" | ||||||
| } | ||||||
| } else if ret.OrderBy != storage.GetStorage().OrderBy || ret.OrderDirection != storage.GetStorage().OrderDirection { | ||||||
| ret.OrderBy = "" | ||||||
| ret.OrderDirection = "" | ||||||
| noSort = true | ||||||
| } | ||||||
| } | ||||||
| if !noExtractFolder && storage.GetStorage().ExtractFolder != "" { | ||||||
| if ret.ExtractFolder == "" { | ||||||
| ret.ExtractFolder = storage.GetStorage().ExtractFolder | ||||||
| } else if ret.ExtractFolder != storage.GetStorage().ExtractFolder { | ||||||
| ret.ExtractFolder = "" | ||||||
| noExtractFolder = true | ||||||
| } | ||||||
| } | ||||||
| if !noSort && !noExtractFolder { | ||||||
|
||||||
| if !noSort && !noExtractFolder { | |
| if noSort && noExtractFolder { |
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.
Potential nil pointer dereference. If all files in the BalancedObjs array are nil or all attempts to get a link fail, the code will reach line 318 with 'link' still being nil, causing a panic when dereferencing it. Add a check to ensure 'link' is not nil before dereferencing, or handle this edge case appropriately.