feat: the backup can include the music, sending each library file once to music/ and again only when it changes (#6774)
release / govulncheck (push) Successful in 15s
release / web (push) Failing after 1m17s
release / go (push) Successful in 1m33s
release / integration (push) Successful in 5m16s
release / android (push) Successful in 5m56s
release / Build signed APK (push) Successful in 6m13s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
release / govulncheck (push) Successful in 15s
release / web (push) Failing after 1m17s
release / go (push) Successful in 1m33s
release / integration (push) Successful in 5m16s
release / android (push) Successful in 5m56s
release / Build signed APK (push) Successful in 6m13s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
With "Include the music" on, each night's run sends the library files the destination doesn't hold yet, after the database file has landed, for up to six hours; a large library spans several nights the first time. Files keep their path under the library folders' common root, beside database/ in the same folder or bucket. backup_music_files records each file's size and mtime as sent, so a night sends only new and changed files, and a rescan that touches a track but finds the same file sends nothing. A changed file goes to its old name; Minstrel never deletes there. An object the bucket refuses (a locked overwrite) is kept with its answer and goes again once the file changes or the settings are saved; three refusals in a row stop the night's music, since that is a key that may not write under music/. A folder copy is written under a .part name and renamed, keeping the file's time. The panel shows how much of the library is in, the refused files, and each run's music count and note. The verdict still turns on the database file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+33
-3
@@ -171,6 +171,17 @@ func (b Bucket) List(ctx context.Context, prefix string, limit int) ([]Object, e
|
||||
}
|
||||
}
|
||||
|
||||
// Refusal is an S3 error response: its HTTP status, S3's code, and the
|
||||
// reason in words. It matches ErrS3.
|
||||
type Refusal struct {
|
||||
Status int
|
||||
Code string
|
||||
text string
|
||||
}
|
||||
|
||||
func (r *Refusal) Error() string { return r.text }
|
||||
func (r *Refusal) Unwrap() error { return ErrS3 }
|
||||
|
||||
// refusal turns an S3 error response into words an admin can act on.
|
||||
func refusal(resp *http.Response) error {
|
||||
var e struct {
|
||||
@@ -185,14 +196,33 @@ func refusal(resp *http.Response) error {
|
||||
"NoSuchBucket": "there is no bucket by that name",
|
||||
"SlowDown": "the server asks to slow down",
|
||||
}[e.Code]
|
||||
r := &Refusal{Status: resp.StatusCode, Code: e.Code}
|
||||
switch {
|
||||
case hint != "":
|
||||
return fmt.Errorf("%w: HTTP %d %s: %s", ErrS3, resp.StatusCode, e.Code, hint)
|
||||
r.text = fmt.Sprintf("%v: HTTP %d %s: %s", ErrS3, resp.StatusCode, e.Code, hint)
|
||||
case e.Code != "":
|
||||
return fmt.Errorf("%w: HTTP %d %s: %s", ErrS3, resp.StatusCode, e.Code, e.Message)
|
||||
r.text = fmt.Sprintf("%v: HTTP %d %s: %s", ErrS3, resp.StatusCode, e.Code, e.Message)
|
||||
default:
|
||||
return fmt.Errorf("%w: HTTP %d", ErrS3, resp.StatusCode)
|
||||
r.text = fmt.Sprintf("%v: HTTP %d", ErrS3, resp.StatusCode)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// ObjectRefused reports whether err is the bucket refusing one object (an
|
||||
// overwrite a write-once target won't take, a name it won't store) rather
|
||||
// than refusing everything: bad keys, a missing bucket, a request to slow
|
||||
// down, or a server error all stop a run instead.
|
||||
func ObjectRefused(err error) bool {
|
||||
var r *Refusal
|
||||
if !errors.As(err, &r) || r.Status/100 != 4 || r.Status == http.StatusTooManyRequests {
|
||||
return false
|
||||
}
|
||||
switch r.Code {
|
||||
case "SignatureDoesNotMatch", "InvalidAccessKeyId", "NoSuchBucket", "SlowDown",
|
||||
"RequestTimeTooSkewed", "ExpiredToken", "InvalidToken":
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func drain(resp *http.Response) {
|
||||
|
||||
Reference in New Issue
Block a user