Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

gosimple friendly

Cette révision appartient à :
akuma06 2017-06-14 09:20:42 +02:00
Parent 05e3391cf9
révision 63fbbaa491
11 fichiers modifiés avec 7 ajouts et 45 suppressions

Voir le fichier

@ -32,13 +32,10 @@ func (st *Status) Parse(s string) {
switch s {
case "1":
*st = FilterRemakes
break
case "2":
*st = Trusted
break
case "3":
*st = APlus
break
default:
*st = ShowAll
}
@ -61,25 +58,18 @@ func (s *SortMode) Parse(str string) {
switch str {
case "1":
*s = Name
break
case "2":
*s = Date
break
case "3":
*s = Downloads
break
case "4":
*s = Size
break
case "5":
*s = Seeders
break
case "6":
*s = Leechers
break
case "7":
*s = Completed
break
default:
*s = ID
}

Voir le fichier

@ -83,11 +83,9 @@ func Configure(conf *config.Config) (err error) {
switch conf.DBType {
case "postgres":
Impl, err = postgres.New(conf.DBParams)
break
case "sqlite3":
err = errSqliteSucksAss
// Impl, err = sqlite.New(conf.DBParams)
break
default:
err = errInvalidDatabaseDialect
}

Voir le fichier

@ -47,9 +47,7 @@ func searchParamToTorrentQuery(param *common.TorrentParam) (q sqlQuery) {
case "completed":
case "last_scrape":
q.query += fmt.Sprintf("AND %s IS NOT NULL ", k)
break
default:
break
}
}
@ -67,9 +65,7 @@ func searchParamToTorrentQuery(param *common.TorrentParam) (q sqlQuery) {
case "completed":
case "last_scrape":
q.query += fmt.Sprintf("AND %s IS NULL ", k)
break
default:
break
}
}
@ -84,25 +80,18 @@ func searchParamToTorrentQuery(param *common.TorrentParam) (q sqlQuery) {
switch param.Sort {
case common.Name:
sort = "torrent_name"
break
case common.Date:
sort = "date"
break
case common.Downloads:
sort = "downloads"
break
case common.Size:
sort = "filesize"
break
case common.Seeders:
sort = "seeders"
break
case common.Leechers:
sort = "leechers"
break
case common.Completed:
sort = "completed"
break
case common.ID:
default:
sort = "torrent_id"

Voir le fichier

@ -294,5 +294,4 @@ func DownloadTorrent(w http.ResponseWriter, r *http.Request) {
// We reset the offset to 0
Openfile.Seek(0, 0)
io.Copy(w, Openfile) //'Copy' the file to the client
return
}

Voir le fichier

@ -38,7 +38,7 @@ func (wh *wrappedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
wrw := wrappedResponseWriter{w, false}
defer r.Body.Close()
wh.h.ServeHTTP(&wrw, r)
if wrw.Ignore == true {
if wrw.Ignore {
wrw.Rw.Header().Del("Content-Encoding")
wrw.Rw.Header().Del("Vary")
wrw.Rw.Header().Set("Content-Type", "text/html; charset=utf-8")

Voir le fichier

@ -245,11 +245,7 @@ func (r *TorrentRequest) ExtractEditInfo(req *http.Request) error {
}
err = r.ExtractLanguage(req)
if err != nil {
return err
}
return nil
return err
}
// ExtractCategory : takes an http request and computes category field for this form

Voir le fichier

@ -122,13 +122,11 @@ func (t *Transaction) GotData(data []byte) (done bool) {
t.ConnectionID = binary.BigEndian.Uint64(data[8:])
}
}
break
case actionScrape:
if len(data) == (12*len(t.swarms))+8 && t.state == stateTransact {
t.handleScrapeReply(data)
}
done = true
break
case actionError:
if len(data) == 12 {
t.handleError(string(data[4:12]))

Voir le fichier

@ -12,8 +12,7 @@ func CreateWhereParams(conditions string, params ...interface{}) WhereParams {
Conditions: conditions,
Params: make([]interface{}, len(params)),
}
for i := range params {
whereParams.Params[i] = params[i]
}
copy(params, whereParams.Params)
return whereParams
}

Voir le fichier

@ -122,9 +122,7 @@ func RegisterHandler(w http.ResponseWriter, r *http.Request) (int, error) {
// CurrentUser determines the current user from the request or context
func CurrentUser(r *http.Request) (model.User, error) {
var user model.User
var encoded string
encoded = r.Header.Get("X-Auth-Token")
encoded := r.Header.Get("X-Auth-Token")
if len(encoded) == 0 {
// check cookie instead
cookie, err := r.Cookie(CookieName)

Voir le fichier

@ -50,8 +50,5 @@ func GetRole(user *model.User) string {
func IsFollower(user *model.User, currentUser *model.User) bool {
var likingUserCount int
db.ORM.Model(&model.UserFollows{}).Where("user_id = ? and following = ?", user.ID, currentUser.ID).Count(&likingUserCount)
if likingUserCount != 0 {
return true
}
return false
return likingUserCount != 0
}

Voir le fichier

@ -16,9 +16,7 @@ func initTorrentLanguages() {
}
// Also support languages we don't have a translation
for _, code := range config.Conf.Torrents.AdditionalLanguages {
torrentLanguages = append(torrentLanguages, code)
}
torrentLanguages = append(torrentLanguages, config.Conf.Torrents.AdditionalLanguages...)
}
// GetTorrentLanguages returns a list of available torrent languages.