forked from wal-g/wal-g
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wal-g:master' into master
- Loading branch information
Showing
7 changed files
with
27 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
package archive | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
type FolderInfo struct { | ||
type AofFolderInfo struct { | ||
Path string | ||
} | ||
|
||
func CreateFolderInfo(path string) *FolderInfo { | ||
return &FolderInfo{ | ||
func CreateAofFolderInfo(path string) *AofFolderInfo { | ||
return &AofFolderInfo{ | ||
Path: path, | ||
} | ||
} | ||
|
||
func (f *FolderInfo) CleanParent() (err error) { | ||
parent := filepath.Dir(f.Path) | ||
starred := filepath.Join(parent, "*") | ||
func (f *AofFolderInfo) CleanData() error { | ||
path := filepath.Clean(f.Path) | ||
err := os.RemoveAll(path) | ||
if err != nil { | ||
return fmt.Errorf("failed to remove AOF folder: %v", err) | ||
} | ||
|
||
parent := filepath.Dir(path) | ||
starred := filepath.Join(parent, "*.rdb") | ||
contents, err := filepath.Glob(starred) | ||
if err != nil { | ||
return | ||
return fmt.Errorf("failed to create glob for rdb files: %v", err) | ||
} | ||
|
||
for _, item := range contents { | ||
err = os.RemoveAll(item) | ||
if err != nil { | ||
return | ||
return fmt.Errorf("failed to remove rdb file: %v", err) | ||
} | ||
} | ||
return | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters