Getting ready to release 0.3.0, changing to new documentation system
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
Settings "github.com/deranjer/goTorrent/settings"
|
||||
Storage "github.com/deranjer/goTorrent/storage"
|
||||
)
|
||||
|
||||
//All the message types are first, first the server handling messages from the client
|
||||
@@ -37,6 +39,15 @@ type RSSFeedsNames struct {
|
||||
RSSFeedURL string
|
||||
}
|
||||
|
||||
//SingleRSSFeedMessage contains the torrents/name/etc of a single torrent feed
|
||||
type SingleRSSFeedMessage struct { //TODO had issues with getting this to work with Storage or Engine
|
||||
MessageType string
|
||||
URL string //the URL of the individual RSS feed
|
||||
Name string
|
||||
TotalTorrents int
|
||||
Torrents []Storage.SingleRSSTorrent //name of the torrents
|
||||
}
|
||||
|
||||
//TorrentList struct contains the torrent list that is sent to the client
|
||||
type TorrentList struct { //helps create the JSON structure that react expects to receive
|
||||
MessageType string `json:"MessageType"`
|
||||
@@ -68,6 +79,11 @@ type TorrentFile struct {
|
||||
FilePriority string //Currently "High", "Normal", or "Cancel"
|
||||
}
|
||||
|
||||
type SettingsFile struct {
|
||||
MessageType string
|
||||
Config Settings.FullClientSettings
|
||||
}
|
||||
|
||||
//ClientDB struct contains the struct that is used to compose the torrentlist
|
||||
type ClientDB struct { //TODO maybe separate out the internal bits into another client struct
|
||||
TorrentHashString string //Passed to client for displaying hash and is used to uniquely identify all torrents
|
||||
|
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/asdine/storm"
|
||||
Settings "github.com/deranjer/goTorrent/settings"
|
||||
Storage "github.com/deranjer/goTorrent/storage"
|
||||
"github.com/mmcdole/gofeed"
|
||||
"github.com/robfig/cron"
|
||||
@@ -21,7 +22,7 @@ func InitializeCronEngine() *cron.Cron {
|
||||
}
|
||||
|
||||
//CheckTorrentWatchFolder adds torrents from a watch folder //TODO see if you can use filepath.Abs instead of changing directory
|
||||
func CheckTorrentWatchFolder(c *cron.Cron, db *storm.DB, tclient *torrent.Client, torrentLocalStorage Storage.TorrentLocal, config FullClientSettings) {
|
||||
func CheckTorrentWatchFolder(c *cron.Cron, db *storm.DB, tclient *torrent.Client, torrentLocalStorage Storage.TorrentLocal, config Settings.FullClientSettings) {
|
||||
c.AddFunc("@every 5m", func() {
|
||||
Logger.WithFields(logrus.Fields{"Watch Folder": config.TorrentWatchFolder}).Info("Running the watch folder cron job")
|
||||
torrentFiles, err := ioutil.ReadDir(config.TorrentWatchFolder)
|
||||
@@ -57,7 +58,7 @@ func CheckTorrentWatchFolder(c *cron.Cron, db *storm.DB, tclient *torrent.Client
|
||||
}
|
||||
|
||||
//RefreshRSSCron refreshes all of the RSS feeds on an hourly basis
|
||||
func RefreshRSSCron(c *cron.Cron, db *storm.DB, tclient *torrent.Client, torrentLocalStorage Storage.TorrentLocal, config FullClientSettings) {
|
||||
func RefreshRSSCron(c *cron.Cron, db *storm.DB, tclient *torrent.Client, torrentLocalStorage Storage.TorrentLocal, config Settings.FullClientSettings) {
|
||||
c.AddFunc("@hourly", func() {
|
||||
torrentHashHistory := Storage.FetchHashHistory(db)
|
||||
RSSFeedStore := Storage.FetchRSSFeeds(db)
|
||||
|
@@ -6,6 +6,7 @@ import (
|
||||
"runtime"
|
||||
|
||||
"github.com/asdine/storm"
|
||||
Settings "github.com/deranjer/goTorrent/settings"
|
||||
Storage "github.com/deranjer/goTorrent/storage"
|
||||
pushbullet "github.com/mitsuse/pushbullet-go"
|
||||
"github.com/mitsuse/pushbullet-go/requests"
|
||||
@@ -14,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
//MoveAndLeaveSymlink takes the file from the default download dir and moves it to the user specified directory and then leaves a symlink behind.
|
||||
func MoveAndLeaveSymlink(config FullClientSettings, tHash string, db *storm.DB, moveDone bool, oldPath string) { //moveDone and oldPath are for moving a completed torrent
|
||||
func MoveAndLeaveSymlink(config Settings.FullClientSettings, tHash string, db *storm.DB, moveDone bool, oldPath string) { //moveDone and oldPath are for moving a completed torrent
|
||||
tStorage := Storage.FetchTorrentFromStorage(db, tHash)
|
||||
Logger.WithFields(logrus.Fields{"Torrent Name": tStorage.TorrentName}).Info("Move and Create symlink started for torrent")
|
||||
var oldFilePath string
|
||||
@@ -77,7 +78,7 @@ func MoveAndLeaveSymlink(config FullClientSettings, tHash string, db *storm.DB,
|
||||
|
||||
}
|
||||
|
||||
func notifyUser(tStorage Storage.TorrentLocal, config FullClientSettings, db *storm.DB) {
|
||||
func notifyUser(tStorage Storage.TorrentLocal, config Settings.FullClientSettings, db *storm.DB) {
|
||||
Logger.WithFields(logrus.Fields{"New File Path": tStorage.StoragePath, "Torrent Name": tStorage.TorrentName}).Info("Attempting to notify user..")
|
||||
tStorage.TorrentMoved = true
|
||||
//Storage.AddTorrentLocalStorage(db, tStorage) //Updating the fact that we moved the torrent
|
||||
|
@@ -4,12 +4,13 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/asdine/storm"
|
||||
Settings "github.com/deranjer/goTorrent/settings"
|
||||
Storage "github.com/deranjer/goTorrent/storage"
|
||||
)
|
||||
|
||||
func TestMoveAndLeaveSymlink(t *testing.T) {
|
||||
type args struct {
|
||||
config FullClientSettings
|
||||
config Settings.FullClientSettings
|
||||
tStorage Storage.TorrentLocal
|
||||
db *storm.DB
|
||||
}
|
||||
@@ -29,7 +30,7 @@ func TestMoveAndLeaveSymlink(t *testing.T) {
|
||||
func Test_notifyUser(t *testing.T) {
|
||||
type args struct {
|
||||
tStorage Storage.TorrentLocal
|
||||
config FullClientSettings
|
||||
config Settings.FullClientSettings
|
||||
db *storm.DB
|
||||
}
|
||||
tests := []struct {
|
||||
|
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
"github.com/asdine/storm"
|
||||
Settings "github.com/deranjer/goTorrent/settings"
|
||||
Storage "github.com/deranjer/goTorrent/storage"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/mmcdole/gofeed"
|
||||
@@ -127,7 +128,7 @@ func readTorrentFileFromDB(element *Storage.TorrentLocal, tclient *torrent.Clien
|
||||
}
|
||||
|
||||
//StartTorrent creates the storage.db entry and starts A NEW TORRENT and adds to the running torrent array
|
||||
func StartTorrent(clientTorrent *torrent.Torrent, torrentLocalStorage Storage.TorrentLocal, torrentDbStorage *storm.DB, torrentType, torrentFilePathAbs, torrentStoragePath, labelValue string, config FullClientSettings) {
|
||||
func StartTorrent(clientTorrent *torrent.Torrent, torrentLocalStorage Storage.TorrentLocal, torrentDbStorage *storm.DB, torrentType, torrentFilePathAbs, torrentStoragePath, labelValue string, config Settings.FullClientSettings) {
|
||||
timedOut := timeOutInfo(clientTorrent, 45) //seeing if adding the torrent times out (giving 45 seconds)
|
||||
if timedOut { //if we fail to add the torrent return
|
||||
return
|
||||
@@ -179,7 +180,7 @@ func StartTorrent(clientTorrent *torrent.Torrent, torrentLocalStorage Storage.To
|
||||
}
|
||||
|
||||
//CreateRunningTorrentArray creates the entire torrent list to pass to client
|
||||
func CreateRunningTorrentArray(tclient *torrent.Client, TorrentLocalArray []*Storage.TorrentLocal, PreviousTorrentArray []ClientDB, config FullClientSettings, db *storm.DB) (RunningTorrentArray []ClientDB) {
|
||||
func CreateRunningTorrentArray(tclient *torrent.Client, TorrentLocalArray []*Storage.TorrentLocal, PreviousTorrentArray []ClientDB, config Settings.FullClientSettings, db *storm.DB) (RunningTorrentArray []ClientDB) {
|
||||
|
||||
for _, singleTorrentFromStorage := range TorrentLocalArray {
|
||||
var singleTorrent *torrent.Torrent
|
||||
@@ -274,7 +275,7 @@ func CreateRunningTorrentArray(tclient *torrent.Client, TorrentLocalArray []*Sto
|
||||
}
|
||||
|
||||
//CreateFileListArray creates a file list for a single torrent that is selected and sent to the server
|
||||
func CreateFileListArray(tclient *torrent.Client, selectedHash string, db *storm.DB, config FullClientSettings) TorrentFileList {
|
||||
func CreateFileListArray(tclient *torrent.Client, selectedHash string, db *storm.DB, config Settings.FullClientSettings) TorrentFileList {
|
||||
runningTorrents := tclient.Torrents() //don't need running torrent array since we aren't adding or deleting from storage
|
||||
torrentFileListStorage := Storage.FetchTorrentFromStorage(db, selectedHash)
|
||||
TorrentFileListSelected := TorrentFileList{}
|
||||
|
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/anacrolix/torrent"
|
||||
Settings "github.com/deranjer/goTorrent/settings"
|
||||
"github.com/deranjer/goTorrent/storage"
|
||||
Storage "github.com/deranjer/goTorrent/storage"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -139,7 +140,7 @@ func CalculateUploadRatio(t *torrent.Torrent, c *ClientDB) string {
|
||||
}
|
||||
|
||||
//CalculateTorrentStatus is used to determine what the STATUS column of the frontend will display ll2
|
||||
func CalculateTorrentStatus(t *torrent.Torrent, c *ClientDB, config FullClientSettings, tFromStorage *storage.TorrentLocal, bytesCompleted int64, totalSize int64) {
|
||||
func CalculateTorrentStatus(t *torrent.Torrent, c *ClientDB, config Settings.FullClientSettings, tFromStorage *storage.TorrentLocal, bytesCompleted int64, totalSize int64) {
|
||||
if (tFromStorage.TorrentStatus == "Stopped") || (float64(c.TotalUploadedBytes)/float64(bytesCompleted) >= config.SeedRatioStop && tFromStorage.TorrentUploadLimit == true) { //If storage shows torrent stopped or if it is over the seeding ratio AND is under the global limit
|
||||
c.Status = "Stopped"
|
||||
c.MaxConnections = 0
|
||||
|
Reference in New Issue
Block a user