Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Łukasz Nowak
caddy
Commits
e26a855d
Commit
e26a855d
authored
Apr 07, 2017
by
Matt Holt
Committed by
GitHub
Apr 07, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1546 from wmark/browse-sort-size
browse: fix arbitrary ordering of directories with sort=size
parents
c0ce2b1d
398d9a6b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
caddyhttp/browse/browse.go
caddyhttp/browse/browse.go
+11
-2
No files found.
caddyhttp/browse/browse.go
View file @
e26a855d
...
...
@@ -165,12 +165,21 @@ func (l bySize) Swap(i, j int) { l.Items[i], l.Items[j] = l.Items[j], l.Items[i]
const
directoryOffset
=
-
1
<<
31
// = math.MinInt32
func
(
l
bySize
)
Less
(
i
,
j
int
)
bool
{
iSize
,
jSize
:=
l
.
Items
[
i
]
.
Size
,
l
.
Items
[
j
]
.
Size
// Directory sizes depend on the filesystem implementation,
// which is opaque to a visitor, and should indeed does not change if the operator choses to change the fs.
// For a consistent user experience directories are pulled to the front…
if
l
.
Items
[
i
]
.
IsDir
{
iSize
=
directoryOffset
+
iSize
iSize
=
directoryOffset
}
if
l
.
Items
[
j
]
.
IsDir
{
jSize
=
directoryOffset
+
jSize
jSize
=
directoryOffset
}
// … and sorted by name.
if
l
.
Items
[
i
]
.
IsDir
&&
l
.
Items
[
j
]
.
IsDir
{
return
strings
.
ToLower
(
l
.
Items
[
i
]
.
Name
)
<
strings
.
ToLower
(
l
.
Items
[
j
]
.
Name
)
}
return
iSize
<
jSize
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment