From cd8d511d3d9a3cc8f368544fc5dbf758b06772e4 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 21 Sep 2020 14:23:40 -0700 Subject: [PATCH] move versionsOrder struct to xl-storage-utils --- cmd/xl-storage-format-utils.go | 14 ++++++++++++++ cmd/xl-storage-format-v2.go | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cmd/xl-storage-format-utils.go b/cmd/xl-storage-format-utils.go index 8ed7854c3..c24a78b91 100644 --- a/cmd/xl-storage-format-utils.go +++ b/cmd/xl-storage-format-utils.go @@ -20,6 +20,20 @@ import ( jsoniter "github.com/json-iterator/go" ) +type versionsSorter []FileInfo + +func (v versionsSorter) Len() int { return len(v) } +func (v versionsSorter) Swap(i, j int) { v[i], v[j] = v[j], v[i] } +func (v versionsSorter) Less(i, j int) bool { + if v[i].IsLatest { + return true + } + if v[j].IsLatest { + return false + } + return v[i].ModTime.After(v[j].ModTime) +} + func getFileInfoVersions(xlMetaBuf []byte, volume, path string) (FileInfoVersions, error) { if isXL2V1Format(xlMetaBuf) { var xlMeta xlMetaV2 diff --git a/cmd/xl-storage-format-v2.go b/cmd/xl-storage-format-v2.go index 79f6d4e95..a9ba76601 100644 --- a/cmd/xl-storage-format-v2.go +++ b/cmd/xl-storage-format-v2.go @@ -525,20 +525,6 @@ func (z xlMetaV2) TotalSize() int64 { return total } -type versionsSorter []FileInfo - -func (v versionsSorter) Len() int { return len(v) } -func (v versionsSorter) Swap(i, j int) { v[i], v[j] = v[j], v[i] } -func (v versionsSorter) Less(i, j int) bool { - if v[i].IsLatest { - return true - } - if v[j].IsLatest { - return false - } - return v[i].ModTime.After(v[j].ModTime) -} - // ListVersions lists current versions, and current deleted // versions returns error for unexpected entries. func (z xlMetaV2) ListVersions(volume, path string) (versions []FileInfo, modTime time.Time, err error) {