aboutsummaryrefslogtreecommitdiff
path: root/steam/package.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2023-01-20 00:35:09 -0500
committerMitchell Riedstra <mitch@riedstra.dev>2023-01-20 00:35:09 -0500
commitf07efbb6fc7a63055a8424799ce03a5f37539873 (patch)
treeff5983b2cae4cc9b8f2f346a47cb3eb23b2f79ae /steam/package.go
parentcbfd82db8a20be32ffa82a1afa860729f3097de6 (diff)
downloadsteam-export-f07efbb6fc7a63055a8424799ce03a5f37539873.tar.gz
steam-export-f07efbb6fc7a63055a8424799ce03a5f37539873.tar.xz
Diffstat (limited to 'steam/package.go')
-rw-r--r--steam/package.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/steam/package.go b/steam/package.go
index db3d6cf..3be5ccf 100644
--- a/steam/package.go
+++ b/steam/package.go
@@ -2,7 +2,6 @@ package steam
import (
"archive/tar"
- "errors"
"io"
"path/filepath"
"time"
@@ -14,7 +13,9 @@ const (
)
func (l *Library) Package(game string, wr io.Writer) error {
+ l.m.Lock()
if _, ok := l.Games()[game]; !ok {
+ l.m.Unlock()
return E_GameDoesNotExist
}
@@ -26,7 +27,7 @@ func (l *Library) Package(game string, wr io.Writer) error {
j.setSize(g.GetSizeBytes())
- // Invert the writer so we can break up the copy and get progress
+ // Invert the writer, so we can break up the copy and get progress
// information in here
rdr, pwrtr := io.Pipe()
go func() {
@@ -51,7 +52,7 @@ func (l *Library) Package(game string, wr io.Writer) error {
total += n
j.setTransferred(total)
- elapsedSeconds := float64(time.Since(*j.StartTime()).Seconds())
+ elapsedSeconds := time.Since(*j.StartTime()).Seconds()
rate := float64(total) / elapsedSeconds
@@ -60,14 +61,14 @@ func (l *Library) Package(game string, wr io.Writer) error {
estSize := j.GetSize()
if estSize == nil {
- j.addError(errors.New("Expected an estimated size, got nil"))
+ j.addError(E_NoEstimatedSize)
continue
}
remainingBytes := float64(*estSize - total)
// fmt.Println("remaining bytes: ", formatBytes(int64(remainingBytes)))
- seconds := (remainingBytes / rate)
+ seconds := remainingBytes / rate
duration := time.Duration(seconds * 1000 * 1000 * 1000)
// fmt.Println("Raw duration: ", duration)
@@ -79,7 +80,7 @@ func (l *Library) Package(game string, wr io.Writer) error {
}
// Package writes the package to wr, returning errors if any
-func (l *Library) packagePrimitive(j *Job, g *Game, wr io.WriteCloser) error {
+func (l *Library) packagePrimitive(g *Game, wr io.WriteCloser) error {
acf, err := FindACF(l.folder, g.Name)
if err != nil {