fs.meta.save: fix directory entry parent path in FullEntry construction (#7886)
* Checkpoint from VS Code for coding agent session * Fix fs.meta.save to correctly save directory's own metadata Co-authored-by: chrislusf <1543151+chrislusf@users.noreply.github.com> * address error --------- Co-authored-by: Chris Lu <chris.lu@gmail.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: chrislusf <1543151+chrislusf@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,8 @@ package shell
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -146,6 +148,29 @@ func doTraverseBfsAndSaving(filerClient filer_pb.FilerClient, writer io.Writer,
|
||||
|
||||
var dirCount, fileCount uint64
|
||||
|
||||
// also save the directory itself (path) if it exists in the filer
|
||||
if e, getErr := filer_pb.GetEntry(context.Background(), filerClient, util.FullPath(path)); getErr != nil {
|
||||
// Entry not found is expected and can be ignored; log other errors.
|
||||
if !errors.Is(getErr, filer_pb.ErrNotFound) {
|
||||
fmt.Fprintf(writer, "failed to get entry %s: %v\n", path, getErr)
|
||||
}
|
||||
} else if e != nil {
|
||||
parentDir, _ := util.FullPath(path).DirAndName()
|
||||
protoMessage := &filer_pb.FullEntry{
|
||||
Dir: parentDir,
|
||||
Entry: e,
|
||||
}
|
||||
if genErr := genFn(protoMessage, outputChan); genErr != nil {
|
||||
fmt.Fprintf(writer, "marshall error: %v\n", genErr)
|
||||
} else {
|
||||
if e.IsDirectory {
|
||||
atomic.AddUint64(&dirCount, 1)
|
||||
} else {
|
||||
atomic.AddUint64(&fileCount, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err := filer_pb.TraverseBfs(filerClient, util.FullPath(path), func(parentPath util.FullPath, entry *filer_pb.Entry) {
|
||||
|
||||
if strings.HasPrefix(string(parentPath), filer.SystemLogDir) {
|
||||
|
||||
Reference in New Issue
Block a user