Allow POSIX platforms only to stop downloads. Windows is another ball of wax, as usual.
This commit is contained in:
parent
f487ff0371
commit
4a5b5009eb
@ -36,6 +36,8 @@ type Download struct {
|
|||||||
|
|
||||||
type Downloads []*Download
|
type Downloads []*Download
|
||||||
|
|
||||||
|
var CanStopDownload = false
|
||||||
|
|
||||||
// StartQueued starts any downloads that have been queued, we would not exceed
|
// StartQueued starts any downloads that have been queued, we would not exceed
|
||||||
// maxRunning. If maxRunning is 0, there is no limit.
|
// maxRunning. If maxRunning is 0, there is no limit.
|
||||||
func (dls Downloads) StartQueued(maxRunning int) {
|
func (dls Downloads) StartQueued(maxRunning int) {
|
||||||
@ -99,6 +101,10 @@ func (dl *Download) Queue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dl *Download) Stop() {
|
func (dl *Download) Stop() {
|
||||||
|
if !CanStopDownload {
|
||||||
|
log.Print("attempted to stop download on a platform that it is not currently supported on - please report this as a bug")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
log.Printf("stopping the download")
|
log.Printf("stopping the download")
|
||||||
dl.mutex.Lock()
|
dl.mutex.Lock()
|
||||||
dl.Log = append(dl.Log, "aborted by user")
|
dl.Log = append(dl.Log, "aborted by user")
|
||||||
|
4
main.go
4
main.go
@ -296,7 +296,7 @@ func fetchHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
templateData := map[string]interface{}{"dl": dl, "config": conf}
|
templateData := map[string]interface{}{"dl": dl, "config": conf, "canStop": download.CanStopDownload}
|
||||||
|
|
||||||
err = t.ExecuteTemplate(w, "layout", templateData)
|
err = t.ExecuteTemplate(w, "layout", templateData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -353,7 +353,7 @@ func fetchHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
templateData := map[string]interface{}{"dl": newDownload, "config": conf}
|
templateData := map[string]interface{}{"dl": newDownload, "config": conf, "canStop": download.CanStopDownload}
|
||||||
|
|
||||||
err = t.ExecuteTemplate(w, "layout", templateData)
|
err = t.ExecuteTemplate(w, "layout", templateData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
</table>
|
</table>
|
||||||
<p>You can close this window and your download will continue. Check the <a href="/" target="_gropple_status">Status page</a> to see all downloads in progress.</p>
|
<p>You can close this window and your download will continue. Check the <a href="/" target="_gropple_status">Status page</a> to see all downloads in progress.</p>
|
||||||
|
{{ if .canStop }}
|
||||||
<button x-show="state=='downloading'" class="pure-button" @click="stop()">stop</button>
|
<button x-show="state=='downloading'" class="pure-button" @click="stop()">stop</button>
|
||||||
|
{{ end }}
|
||||||
<div>
|
<div>
|
||||||
<h4>Logs</h4>
|
<h4>Logs</h4>
|
||||||
<pre x-text="log">
|
<pre x-text="log">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user