fixes
This commit is contained in:
@@ -224,6 +224,11 @@ func (c *Client) Pull(gameID, archivePath string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open file: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := os.Rename(archivePath+".part", archivePath); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
defer f.Close()
|
||||
|
||||
res, err := cli.Do(req)
|
||||
@@ -246,8 +251,10 @@ func (c *Client) Pull(gameID, archivePath string) error {
|
||||
return fmt.Errorf("an error occured while copying the file from the remote: %w", err)
|
||||
}
|
||||
|
||||
if err := os.Rename(archivePath+".part", archivePath); err != nil {
|
||||
return fmt.Errorf("failed to move temporary data: %w", err)
|
||||
if err := os.Remove(archivePath); err != nil {
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
return fmt.Errorf("failed to remove the old version of the archive: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user