Skip to content

Commit d2f477c

Browse files
resolved -> absolute wording for clarity
1 parent c0355ed commit d2f477c

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

pkg/snapshot/snapshot.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ func isHttpURL(str string) bool {
5959
return u.Scheme == "http" || u.Scheme == "https"
6060
}
6161

62-
// resolveFilePath expands the ~ in file paths to the user's home directory and converts relative paths to absolute paths.
63-
func resolveFilePath(path string) (string, error) {
62+
// getAbsoluteFilePath expands the ~ in file paths to the user's home directory and converts relative paths to absolute paths.
63+
func getAbsoluteFilePath(path string) (string, error) {
6464
if path == "" {
6565
return "", nil
6666
}
@@ -80,12 +80,12 @@ func resolveFilePath(path string) (string, error) {
8080

8181
// CreateSnapshot creates a snapshot of the database based on the provided configuration.
8282
func (s *SnapshotService) CreateSnapshot() error {
83-
resolvedFilePath, err := resolveFilePath(s.cfg.OutputFile)
83+
absoluteFilePath, err := getAbsoluteFilePath(s.cfg.OutputFile)
8484
if err != nil {
8585
return errors.Wrap(err, fmt.Sprintf("failed to resolve output file path '%s'", s.cfg.OutputFile))
8686
}
8787

88-
s.l.Sugar().Debugw("Resolved file paths", zap.String("Output", resolvedFilePath))
88+
s.l.Sugar().Debugw("Absolute file path", zap.String("Output", absoluteFilePath))
8989

9090
if err := s.validateCreateSnapshotConfig(); err != nil {
9191
return err
@@ -107,8 +107,8 @@ func (s *SnapshotService) CreateSnapshot() error {
107107

108108
s.l.Sugar().Infow("Successfully created snapshot")
109109

110-
outputHashFile := getHashName(resolvedFilePath)
111-
if err := saveOutputFileHash(resolvedFilePath, outputHashFile); err != nil {
110+
outputHashFile := getHashName(absoluteFilePath)
111+
if err := saveOutputFileHash(absoluteFilePath, outputHashFile); err != nil {
112112
return errors.Wrap(err, fmt.Sprintf("failed to save output file hash '%s'", outputHashFile))
113113
}
114114

@@ -122,7 +122,7 @@ func (s *SnapshotService) RestoreSnapshot() error {
122122
s.tempFiles = s.tempFiles[:0] // Clear the tempFiles slice after cleanup
123123
}()
124124

125-
var resolvedFilePath string
125+
var absoluteFilePath string
126126
if isHttpURL(s.cfg.Input) {
127127
inputUrl := s.cfg.Input
128128

@@ -152,28 +152,28 @@ func (s *SnapshotService) RestoreSnapshot() error {
152152
}
153153
s.tempFiles = append(s.tempFiles, inputFilePath)
154154

155-
resolvedFilePath, err = resolveFilePath(inputFilePath)
155+
absoluteFilePath, err = getAbsoluteFilePath(inputFilePath)
156156
if err != nil {
157157
return errors.Wrap(err, fmt.Sprintf("failed to resolve input file path '%s'", inputFilePath))
158158
}
159159
} else {
160160
var err error
161-
resolvedFilePath, err = resolveFilePath(s.cfg.Input)
161+
absoluteFilePath, err = getAbsoluteFilePath(s.cfg.Input)
162162
if err != nil {
163163
return errors.Wrap(err, fmt.Sprintf("failed to resolve input file path '%s'", s.cfg.Input))
164164
}
165165
}
166166

167-
s.l.Sugar().Debugw("Resolved file path", zap.String("resolvedFilePath", resolvedFilePath))
167+
s.l.Sugar().Debugw("absolute file path", zap.String("absoluteFilePath", absoluteFilePath))
168168

169169
// validate snapshot against the hash file
170170
if s.cfg.VerifyInput {
171-
if err := validateInputFileHash(resolvedFilePath); err != nil {
172-
return errors.Wrap(err, fmt.Sprintf("input file hash validation failed for '%s'", resolvedFilePath))
171+
if err := validateInputFileHash(absoluteFilePath); err != nil {
172+
return errors.Wrap(err, fmt.Sprintf("input file hash validation failed for '%s'", absoluteFilePath))
173173
}
174174
s.l.Sugar().Debugw("Input file hash validated successfully",
175-
zap.String("input", resolvedFilePath),
176-
zap.String("inputHashFile", getHashName(resolvedFilePath)),
175+
zap.String("input", absoluteFilePath),
176+
zap.String("inputHashFile", getHashName(absoluteFilePath)),
177177
)
178178
}
179179

@@ -182,7 +182,7 @@ func (s *SnapshotService) RestoreSnapshot() error {
182182
return err
183183
}
184184

185-
restoreExec := restore.Exec(resolvedFilePath, pgcommands.ExecOptions{StreamPrint: false})
185+
restoreExec := restore.Exec(absoluteFilePath, pgcommands.ExecOptions{StreamPrint: false})
186186
if restoreExec.Error != nil {
187187
s.l.Sugar().Errorw("Failed to restore from snapshot",
188188
zap.Error(restoreExec.Error.Err),
@@ -223,11 +223,11 @@ func (s *SnapshotService) setupSnapshotDump() (*pgcommands.Dump, error) {
223223
if s.cfg.SchemaName != "" {
224224
dump.Options = append(dump.Options, fmt.Sprintf("--schema=%s", s.cfg.SchemaName))
225225
}
226-
resolvedFilePath, err := resolveFilePath(s.cfg.OutputFile)
226+
absoluteFilePath, err := getAbsoluteFilePath(s.cfg.OutputFile)
227227
if err != nil {
228228
return nil, errors.Wrap(err, fmt.Sprintf("failed to resolve output file path '%s'", s.cfg.OutputFile))
229229
}
230-
dump.SetFileName(resolvedFilePath)
230+
dump.SetFileName(absoluteFilePath)
231231

232232
return dump, nil
233233
}

0 commit comments

Comments
 (0)