Bump all dependencies

This commit is contained in:
Matthew Penner
2020-12-27 11:49:08 -07:00
parent ddb683efb6
commit a4c8b8714b
13 changed files with 282 additions and 160 deletions

View File

@@ -49,8 +49,7 @@ func (a *Archive) Create(dst string) error {
// Select a writer based off of the WriteLimit configuration option. If there is no
// write limit, use the file as the writer.
var writer io.Writer = f
writeLimit := int64(config.Get().System.Backups.WriteLimit * 1024 * 1024)
if writeLimit > 0 {
if writeLimit := int64(config.Get().System.Backups.WriteLimit * 1024 * 1024); writeLimit > 0 {
// Token bucket with a capacity of "writeLimit" MiB, adding "writeLimit" MiB/s
// and then wrap the file writer with the token bucket limiter.
writer = ratelimit.Writer(f, ratelimit.NewBucketWithRate(float64(writeLimit), writeLimit))
@@ -199,9 +198,11 @@ func (a *Archive) addToArchive(p string, rp string, w *tar.Writer) error {
return errors.WithMessagef(err, "failed to open '%s' for copying", header.Name)
}
defer f.Close()
// Copy the file's contents to the archive using our buffer.
if _, err := io.CopyBuffer(w, io.LimitReader(f, header.Size), buf); err != nil {
return errors.WithMessagef(err, "failed to copy '%s' to archive", header.Name)
}
return nil
}

View File

@@ -264,7 +264,7 @@ func (fs *Filesystem) Chmod(path string, mode os.FileMode) error {
// looping endlessly.
func (fs *Filesystem) findCopySuffix(dir string, name string, extension string) (string, error) {
var i int
var suffix = " copy"
suffix := " copy"
for i = 0; i < 51; i++ {
if i > 0 {