Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Commit

Permalink
change format
Browse files Browse the repository at this point in the history
  • Loading branch information
shengxiang committed Oct 29, 2015
1 parent 8457ec7 commit 68e41b2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
7 changes: 7 additions & 0 deletions data/.gohttp.yml
@@ -0,0 +1,7 @@
---
mount:
type: qiniu
config:
access_key: asksjdfasdfasd
secret_key: lksajdfkjasdfk
bucket: gobuild3-test
16 changes: 0 additions & 16 deletions routers/dir.go
Expand Up @@ -11,22 +11,6 @@ import (
"gopkg.in/macaron.v1"
)

func formatSize(file os.FileInfo) string {
if file.IsDir() {
return "-"
}
size := file.Size()
switch {
case size > 1024*1024:
return fmt.Sprintf("%.1fM", float64(size)/1024/1024)
case size > 1024:
return fmt.Sprintf("%.1fK", float64(size)/1024)
default:
return strconv.Itoa(int(size))
}
return ""
}

func deepPath(basedir, name string) string {
isDir := true
for isDir {
Expand Down
23 changes: 23 additions & 0 deletions routers/utils.go
@@ -0,0 +1,23 @@
package routers

import (
"fmt"
"os"
"strconv"
)

func formatSize(file os.FileInfo) string {
if file.IsDir() {
return "-"
}
size := file.Size()
switch {
case size > 1024*1024:
return fmt.Sprintf("%.1fM", float64(size)/1024/1024)
case size > 1024:
return fmt.Sprintf("%.1fK", float64(size)/1024)
default:
return strconv.Itoa(int(size))
}
return ""
}

0 comments on commit 68e41b2

Please sign in to comment.