Gofmt friendly (#752)
Keeping Go source code in line with what they preconize
Cette révision appartient à :
Parent
2da1c88c64
révision
c3211c6a14
6 fichiers modifiés avec 38 ajouts et 41 suppressions
|
@ -47,4 +47,4 @@ var TorrentCleanCategories = map[string]string{
|
||||||
"1_": "software",
|
"1_": "software",
|
||||||
"1_1": "software_applications",
|
"1_1": "software_applications",
|
||||||
"1_2": "software_games",
|
"1_2": "software_games",
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,4 +41,3 @@ func (f *File) Filename() string {
|
||||||
path := f.Path()
|
path := f.Path()
|
||||||
return path[len(path)-1]
|
return path[len(path)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TorrentStatusNormal = 1
|
TorrentStatusNormal = 1
|
||||||
TorrentStatusRemake = 2
|
TorrentStatusRemake = 2
|
||||||
TorrentStatusTrusted = 3
|
TorrentStatusTrusted = 3
|
||||||
TorrentStatusAPlus = 4
|
TorrentStatusAPlus = 4
|
||||||
TorrentStatusBlocked = 5
|
TorrentStatusBlocked = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
type Feed struct {
|
type Feed struct {
|
||||||
|
|
|
@ -130,9 +130,9 @@ func getTorrentsOrderBy(parameters *serviceBase.WhereParams, orderBy string, lim
|
||||||
if !deleted {
|
if !deleted {
|
||||||
conditionArray = append(conditionArray, "deleted_at IS NULL")
|
conditionArray = append(conditionArray, "deleted_at IS NULL")
|
||||||
} else {
|
} else {
|
||||||
conditionArray = append(conditionArray, "deleted_at NOT NULL")
|
conditionArray = append(conditionArray, "deleted_at NOT NULL")
|
||||||
}
|
}
|
||||||
|
|
||||||
conditions := strings.Join(conditionArray, " AND ")
|
conditions := strings.Join(conditionArray, " AND ")
|
||||||
|
|
||||||
if countAll {
|
if countAll {
|
||||||
|
@ -225,7 +225,7 @@ func ToggleBlockTorrent(id string) (model.Torrent, int, error) {
|
||||||
if torrent.Status == model.TorrentStatusBlocked {
|
if torrent.Status == model.TorrentStatusBlocked {
|
||||||
torrent.Status = model.TorrentStatusNormal
|
torrent.Status = model.TorrentStatusNormal
|
||||||
} else {
|
} else {
|
||||||
torrent.Status = model.TorrentStatusBlocked
|
torrent.Status = model.TorrentStatusBlocked
|
||||||
}
|
}
|
||||||
if db.ORM.Unscoped().Model(&torrent).UpdateColumn(&torrent).Error != nil {
|
if db.ORM.Unscoped().Model(&torrent).UpdateColumn(&torrent).Error != nil {
|
||||||
return torrent, http.StatusInternalServerError, errors.New("Torrent was not updated.")
|
return torrent, http.StatusInternalServerError, errors.New("Torrent was not updated.")
|
||||||
|
@ -244,4 +244,4 @@ func UpdateTorrent(torrent model.Torrent) (int, error) {
|
||||||
func GetDeletedTorrents(parameters *serviceBase.WhereParams, orderBy string, limit int, offset int) (torrents []model.Torrent, count int, err error) {
|
func GetDeletedTorrents(parameters *serviceBase.WhereParams, orderBy string, limit int, offset int) (torrents []model.Torrent, count int, err error) {
|
||||||
torrents, count, err = getTorrentsOrderBy(parameters, orderBy, limit, offset, true, true, true)
|
torrents, count, err = getTorrentsOrderBy(parameters, orderBy, limit, offset, true, true, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
package filelist;
|
package filelist
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bradfitz/slice"
|
|
||||||
"github.com/NyaaPantsu/nyaa/model"
|
|
||||||
"html/template"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"strings"
|
"github.com/NyaaPantsu/nyaa/model"
|
||||||
|
"github.com/bradfitz/slice"
|
||||||
|
"html/template"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileListFolder struct {
|
type FileListFolder struct {
|
||||||
Folders map[string]*FileListFolder
|
Folders map[string]*FileListFolder
|
||||||
Files []model.File
|
Files []model.File
|
||||||
}
|
}
|
||||||
|
|
||||||
func FileListToFolder(fileList []model.File) (out *FileListFolder) {
|
func FileListToFolder(fileList []model.File) (out *FileListFolder) {
|
||||||
|
@ -27,10 +27,10 @@ func FileListToFolder(fileList []model.File) (out *FileListFolder) {
|
||||||
|
|
||||||
if len(pathArray) > 1 {
|
if len(pathArray) > 1 {
|
||||||
pathStrippedFile := model.File{
|
pathStrippedFile := model.File{
|
||||||
ID: file.ID,
|
ID: file.ID,
|
||||||
TorrentID: file.TorrentID,
|
TorrentID: file.TorrentID,
|
||||||
BencodedPath: "",
|
BencodedPath: "",
|
||||||
Filesize: file.Filesize,
|
Filesize: file.Filesize,
|
||||||
}
|
}
|
||||||
pathStrippedFile.SetPath(pathArray[1:])
|
pathStrippedFile.SetPath(pathArray[1:])
|
||||||
pathsToFolders[pathArray[0]] = append(pathsToFolders[pathArray[0]], pathStrippedFile)
|
pathsToFolders[pathArray[0]] = append(pathsToFolders[pathArray[0]], pathStrippedFile)
|
||||||
|
@ -59,19 +59,19 @@ func (f *FileListFolder) TotalSize() (out int64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type folderFormatData struct {
|
type folderFormatData struct {
|
||||||
Data interface{}
|
Data interface{}
|
||||||
FolderName string
|
FolderName string
|
||||||
TotalSize int64
|
TotalSize int64
|
||||||
NestLevel uint
|
NestLevel uint
|
||||||
ParentIdentifier string
|
ParentIdentifier string
|
||||||
Identifier string
|
Identifier string
|
||||||
}
|
}
|
||||||
|
|
||||||
type fileFormatData struct {
|
type fileFormatData struct {
|
||||||
Data interface{}
|
Data interface{}
|
||||||
Filename string
|
Filename string
|
||||||
Filesize int64
|
Filesize int64
|
||||||
NestLevel uint
|
NestLevel uint
|
||||||
ParentIdentifier string
|
ParentIdentifier string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ func (f *FileListFolder) makeFolderTreeView(folderTmpl *template.Template, fileT
|
||||||
}
|
}
|
||||||
output += tmp
|
output += tmp
|
||||||
|
|
||||||
tmp, err = folder.makeFolderTreeView(folderTmpl, fileTmpl, nestLevel + 1, childIdentifier, data)
|
tmp, err = folder.makeFolderTreeView(folderTmpl, fileTmpl, nestLevel+1, childIdentifier, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -141,4 +141,3 @@ func (f *FileListFolder) MakeFolderTreeView(folderFormat string, fileFormat stri
|
||||||
output, err = f.makeFolderTreeView(folderTmpl, fileTmpl, 0, "root", data)
|
output, err = f.makeFolderTreeView(folderTmpl, fileTmpl, 0, "root", data)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package filelist;
|
package filelist
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"html/template"
|
|
||||||
"github.com/NyaaPantsu/nyaa/model"
|
"github.com/NyaaPantsu/nyaa/model"
|
||||||
|
"html/template"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeDummyFile(path ...string) (file model.File) {
|
func makeDummyFile(path ...string) (file model.File) {
|
||||||
|
@ -25,12 +25,12 @@ func TestFilelist(T *testing.T) {
|
||||||
makeDummyFile("A", "C", "C.txt"),
|
makeDummyFile("A", "C", "C.txt"),
|
||||||
makeDummyFile("B.txt"),
|
makeDummyFile("B.txt"),
|
||||||
}
|
}
|
||||||
expected := "A\n"+
|
expected := "A\n" +
|
||||||
"-B\n"+
|
"-B\n" +
|
||||||
"--C.txt\n"+
|
"--C.txt\n" +
|
||||||
"-C\n"+
|
"-C\n" +
|
||||||
"--C.txt\n"+
|
"--C.txt\n" +
|
||||||
"B.txt\n"
|
"B.txt\n"
|
||||||
|
|
||||||
filelist := FileListToFolder(files)
|
filelist := FileListToFolder(files)
|
||||||
|
|
||||||
|
@ -46,4 +46,3 @@ func TestFilelist(T *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Référencer dans un nouveau ticket