Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/model/file.go
ElegantMonkey 7d8cbe1393 Add Upload and Download limiters, rely on unique_index for avoiding duplicates
The FileList that is read with GetTorrents is empty, as it's only loaded with
GetTorrentById. So, always insert the new FileList on the database, and rely on
the unique_index to avoid duplications.
2017-05-14 11:35:03 -03:00

15 lignes
397 o
Go

package model
type File struct {
ID uint `gorm:"column:file_id;primary_key"`
TorrentID uint `gorm:"column:torrent_id;unique_index:idx_tid_path"`
Path string `gorm:"column:path;unique_index:idx_tid_path"`
Filesize int64 `gorm:"column:filesize"`
}
// Returns the total size of memory allocated for this struct
func (f File) Size() int {
return (2 + len(f.Path) + 2) * 8;
}