diff options
Diffstat (limited to 'steam/package.go')
| -rw-r--r-- | steam/package.go | 13 |
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 { |
