Skip to content

Commit 45c68a3

Browse files
committed
chore: cleanup command
1 parent e63042c commit 45c68a3

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

cmd/restore.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"github.com/spf13/cobra"
1010
)
1111

12-
var tempDir string
13-
1412
var RestoreCmd = &cobra.Command{
1513
Use: "restore",
1614
Short: "Restore the current scroll",
@@ -34,5 +32,4 @@ var RestoreCmd = &cobra.Command{
3432
}
3533

3634
func init() {
37-
RestoreCmd.Flags().StringVarP(&tempDir, "temp-dir", "", "", "Temporary directory where to move the soon to be deleted files to. Files will be restored, in case an error occured while fetching / extracting the snapshot. Only works when --skip-safety is not set.")
3835
}

internal/core/services/snapshot/restore_service.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"io"
1111
"net/http"
1212
"os"
13-
"path"
1413
"path/filepath"
1514
"strings"
1615

@@ -144,16 +143,10 @@ func (rc *SnapshotService) RestoreSnapshot(dir string, source string, options po
144143

145144
progressReader := &ProgressTracker{}
146145

147-
tmpDir := os.TempDir()
148-
dest := path.Join(tmpDir, ".snap_dl")
149-
150-
os.RemoveAll(dest)
151-
defer os.RemoveAll(dest)
152-
153146
// Create a new client
154147
client := &getter.Client{
155148
Src: source, // Source URL
156-
Dst: dest,
149+
Dst: dir,
157150
Mode: getter.ClientModeDir,
158151
ProgressListener: progressReader,
159152
}
@@ -178,17 +171,10 @@ func (rc *SnapshotService) RestoreSnapshot(dir string, source string, options po
178171
// Download the file
179172
err = client.Get()
180173
if err != nil {
181-
os.RemoveAll(dest)
182174
logger.Log().Error("Error occured while getting backup", zap.Error(err))
183175
return err
184176
}
185177

186-
// Move the downloaded file to the destination
187-
err = utils.MoveContents(dest, dir)
188-
if err != nil {
189-
return err
190-
}
191-
192178
logger.Log().Info("Backup restored", zap.String("source", source), zap.String("destination", dir))
193179
return nil
194180
}

0 commit comments

Comments
 (0)