Adjust code style

This commit is contained in:
Marius 2015-11-26 12:43:31 +01:00
parent 38e0a4759b
commit 7b1cf1f639
1 changed files with 17 additions and 17 deletions

View File

@ -14,8 +14,8 @@ package limitedstore
import ( import (
"github.com/tus/tusd" "github.com/tus/tusd"
"sync"
"sort" "sort"
"sync"
) )
type LimitedStore struct { type LimitedStore struct {
@ -40,7 +40,6 @@ func (p pairlist) Len() int { return len(p) }
func (p pairlist) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p pairlist) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func (p pairlist) Less(i, j int) bool { return p[i].value < p[j].value } func (p pairlist) Less(i, j int) bool { return p[i].value < p[j].value }
// Create a new limited store with the given size as the maximum storage size // Create a new limited store with the given size as the maximum storage size
func New(storeSize int64, dataStore tusd.DataStore) *LimitedStore { func New(storeSize int64, dataStore tusd.DataStore) *LimitedStore {
return &LimitedStore{ return &LimitedStore{
@ -97,18 +96,19 @@ func (store *LimitedStore) ensureSpace(size int64) error {
// Enough space is available to store the new upload // Enough space is available to store the new upload
return nil return nil
} }
sorted_uploads := make(pairlist, len(store.uploads))
sortedUploads := make(pairlist, len(store.uploads))
i := 0 i := 0
for u,h := range store.uploads { for u, h := range store.uploads {
sorted_uploads[i] = pair{u, h} sortedUploads[i] = pair{u, h}
i++ i++
} }
sort.Sort(sort.Reverse(sorted_uploads)) sort.Sort(sort.Reverse(sortedUploads))
// Forward traversal through the // Forward traversal through the uploads in terms of size, biggest upload first
// uploads in terms of size, biggest upload first for _, k := range sortedUploads {
for _,k := range sorted_uploads {
id := k.key id := k.key
if err := store.terminate(id); err != nil { if err := store.terminate(id); err != nil {
return err return err
} }