Skip to content

Commit

Permalink
fix: cannot backup files under backup root
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelncui committed Oct 20, 2023
1 parent 97569fd commit ecfce73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions executor/job_archive_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ func (a *jobArchiveExecutor) applyParam(ctx context.Context, param *entity.JobAr
if src.Base[0] != '/' {
src.Base = path.Join(a.exe.paths.Source, src.Base) + "/"
}
a.logger.Infof("walk source start, source_path= '%s'", src.RealPath())

sources, err = a.walk(ctx, src, sources)
if err != nil {
return err
}
a.logger.Infof("walk source finished, source_path= '%s' current_source_len= %d", src.RealPath(), len(sources))
}
sort.Slice(sources, func(i, j int) bool {
return sources[i].Source.Compare(sources[j].Source) < 0
})
a.logger.Infof("walk source all finished, get %d sources", len(sources))

for idx, src := range sources {
if idx > 0 && sources[idx-1].Source.Equal(src.Source) {
Expand All @@ -68,6 +71,7 @@ func (a *jobArchiveExecutor) walk(ctx context.Context, src *entity.Source, sourc
mode := stat.Mode()
if mode.IsRegular() {
if stat.Name() == ".DS_Store" {
a.logger.Infof("walk ignore file, reason= 'ignore .DS_Store' path= %s", path)
return sources, nil
}
return append(sources, &entity.SourceState{
Expand All @@ -77,6 +81,7 @@ func (a *jobArchiveExecutor) walk(ctx context.Context, src *entity.Source, sourc
}), nil
}
if mode&acp.UnexpectFileMode != 0 {
a.logger.Infof("walk ignore file, reason= 'ignore unexpected file mode' path= %s mode= %O mask= %O", path, mode, acp.UnexpectFileMode)
return sources, nil
}

Expand Down
8 changes: 6 additions & 2 deletions frontend/src/pages/backup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,22 @@ const useBackupTargetBrowser = () => {
const sources = files
.map((file) => {
if (!file) {
return undefined;
console.log('create backup job, cannot get file')
return;
}

let path = file.id.trim();
if (path.length === 0) {
console.log('create backup job, file id is too short', file)
return;
}
while (path.endsWith("/")) {
path = path.slice(0, -1);
}
const splitIdx = path.lastIndexOf("/");

let splitIdx = path.lastIndexOf("/");
if (splitIdx < 0) {
splitIdx = -1
return;
}

Expand Down

0 comments on commit ecfce73

Please sign in to comment.