Skip to content

Commit 3767b8a

Browse files
authored
fix(backup): create directory before writing backup (#8638)
We used to create the directory while creating a backup if one didn't exist. Slash branch doesn't create one but I think we should continue with the behaviour of creating a directory as was there in main branch.
1 parent 09d9293 commit 3767b8a

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

worker/backup_ee.go

+5
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ func ProcessBackupRequest(ctx context.Context, req *pb.BackupRequest) error {
147147
if err != nil {
148148
return err
149149
}
150+
if !handler.DirExists("./") {
151+
if err := handler.CreateDir("./"); err != nil {
152+
return errors.Wrap(err, "while creating backup directory")
153+
}
154+
}
150155
latestManifest, err := GetLatestManifest(handler, uri)
151156
if err != nil {
152157
return err

worker/backup_handler.go

-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ const (
6262
)
6363

6464
func createBackupFile(h UriHandler, uri *url.URL, req *pb.BackupRequest) (io.WriteCloser, error) {
65-
if !h.DirExists("./") {
66-
if err := h.CreateDir("./"); err != nil {
67-
return nil, errors.Wrap(err, "while creating backup file")
68-
}
69-
}
7065
fileName := backupName(req.ReadTs, req.GroupId)
7166
dir := fmt.Sprintf(backupPathFmt, req.UnixTs)
7267
if err := h.CreateDir(dir); err != nil {

worker/backup_manifest.go

-7
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,6 @@ func GetManifest(h UriHandler, uri *url.URL) (*MasterManifest, error) {
213213
}
214214

215215
func createManifest(h UriHandler, uri *url.URL, manifest *MasterManifest) error {
216-
var err error
217-
if !h.DirExists("./") {
218-
if err := h.CreateDir("./"); err != nil {
219-
return errors.Wrap(err, "createManifest failed to create path: ")
220-
}
221-
}
222-
223216
w, err := h.CreateFile(tmpManifest)
224217
if err != nil {
225218
return errors.Wrap(err, "createManifest failed to create tmp path: ")

0 commit comments

Comments
 (0)