From d62cdc70da01d2ed3b905147d68e1efd94f824e6 Mon Sep 17 00:00:00 2001 From: MichaelOultram Date: Tue, 28 Jul 2015 13:43:43 +0100 Subject: [PATCH] Precaching --- songqueue.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/songqueue.go b/songqueue.go index 67db542..cc773c1 100644 --- a/songqueue.go +++ b/songqueue.go @@ -30,6 +30,12 @@ func (q *SongQueue) AddSong(s Song) error { beforeLen := q.Len() q.queue = append(q.queue, s) if len(q.queue) == beforeLen+1 { + + // Caching as added to queue + if dj.conf.Cache.Enabled && c.GetCurrentTotalFileSize() > (dj.conf.Cache.MaximumSize*1048576) { + s.Download() + } + return nil } return errors.New("Could not add Song to the SongQueue.")