Add state reasons
This commit is contained in:
parent
ada43b176b
commit
3497bfd194
@ -25,12 +25,13 @@ import (
|
|||||||
type State string
|
type State string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
StatePending State = "Pending" // waiting for decision to upload (could be edited)
|
StatePending State = "Pending" // waiting for decision to upload (could be edited)
|
||||||
StateQueued State = "Queued" // ready for upload
|
StateQueued State = "Queued" // ready for upload
|
||||||
StateUploading State = "Uploading" // uploading
|
StateWatermarking State = "Adding Watermark" // thumbnail generation
|
||||||
StateComplete State = "Complete" // finished successfully
|
StateUploading State = "Uploading" // uploading
|
||||||
StateFailed State = "Failed" // failed
|
StateComplete State = "Complete" // finished successfully
|
||||||
StateSkipped State = "Skipped" // user did not want to upload
|
StateFailed State = "Failed" // failed
|
||||||
|
StateSkipped State = "Skipped" // user did not want to upload
|
||||||
)
|
)
|
||||||
|
|
||||||
var currentId int32
|
var currentId int32
|
||||||
@ -56,7 +57,11 @@ type Upload struct {
|
|||||||
|
|
||||||
Url string `json:"url"` // url on the discord CDN
|
Url string `json:"url"` // url on the discord CDN
|
||||||
|
|
||||||
State State `json:"state"`
|
Width int `json:"width"`
|
||||||
|
Height int `json:"height"`
|
||||||
|
|
||||||
|
State State `json:"state"`
|
||||||
|
StateReason string `json:"state_reason"`
|
||||||
|
|
||||||
Client HTTPClient `json:"-"`
|
Client HTTPClient `json:"-"`
|
||||||
}
|
}
|
||||||
@ -85,6 +90,7 @@ func (u *Uploader) AddFile(file string, conf config.Watcher) {
|
|||||||
// set it to Pending instead
|
// set it to Pending instead
|
||||||
if conf.HoldUploads {
|
if conf.HoldUploads {
|
||||||
thisUpload.State = StatePending
|
thisUpload.State = StatePending
|
||||||
|
thisUpload.StateReason = ""
|
||||||
}
|
}
|
||||||
u.Uploads = append(u.Uploads, &thisUpload)
|
u.Uploads = append(u.Uploads, &thisUpload)
|
||||||
u.Lock.Unlock()
|
u.Lock.Unlock()
|
||||||
@ -180,6 +186,7 @@ func (u *Upload) processUpload() error {
|
|||||||
// just fail immediately, we know this means the file was too big
|
// just fail immediately, we know this means the file was too big
|
||||||
daulog.Error("413 received - file too large")
|
daulog.Error("413 received - file too large")
|
||||||
u.State = StateFailed
|
u.State = StateFailed
|
||||||
|
u.StateReason = "discord API said file too large"
|
||||||
return errors.New("received 413 - file too large")
|
return errors.New("received 413 - file too large")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +239,9 @@ func (u *Upload) processUpload() error {
|
|||||||
|
|
||||||
u.Url = a.URL
|
u.Url = a.URL
|
||||||
u.State = StateComplete
|
u.State = StateComplete
|
||||||
|
u.StateReason = ""
|
||||||
|
u.Width = a.Width
|
||||||
|
u.Height = a.Height
|
||||||
u.UploadedAt = time.Now()
|
u.UploadedAt = time.Now()
|
||||||
|
|
||||||
break
|
break
|
||||||
@ -245,6 +254,7 @@ func (u *Upload) processUpload() error {
|
|||||||
if retriesRemaining == 0 {
|
if retriesRemaining == 0 {
|
||||||
daulog.Error("Failed to upload, even after all retries")
|
daulog.Error("Failed to upload, even after all retries")
|
||||||
u.State = StateFailed
|
u.State = StateFailed
|
||||||
|
u.StateReason = "could not upload after all retries"
|
||||||
return errors.New("could not upload after all retries")
|
return errors.New("could not upload after all retries")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>filename</th>
|
<th>filename</th>
|
||||||
<th>actions</th>
|
<th>state</th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -48,8 +48,10 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td x-text="ul.original_file"></td>
|
<td x-text="ul.original_file"></td>
|
||||||
<td>
|
<td>
|
||||||
<button @click="start_upload(ul.id)" type="button" class="btn btn-primary">upload</button>
|
<span x-text="ul.state"></span>
|
||||||
</td>
|
<div x-if="ul.state_reason">(<span x-text="ul.state_reason"></span>)</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<img :src="'/rest/image/'+ul.id+'/thumb'">
|
<img :src="'/rest/image/'+ul.id+'/thumb'">
|
||||||
</td>
|
</td>
|
||||||
@ -74,7 +76,10 @@
|
|||||||
<template x-for="ul in finished">
|
<template x-for="ul in finished">
|
||||||
<tr>
|
<tr>
|
||||||
<td x-text="ul.original_file"></td>
|
<td x-text="ul.original_file"></td>
|
||||||
<td x-text="ul.state"></td>
|
<td>
|
||||||
|
<span x-text="ul.state"></span>
|
||||||
|
<div x-if="ul.state_reason">(<span x-text="ul.state_reason"></span>)</div>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<img :src="'/rest/image/'+ul.id+'/thumb'">
|
<img :src="'/rest/image/'+ul.id+'/thumb'">
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user