paveon commented on code in PR #1133:
URL: https://github.com/apache/iceberg-go/pull/1133#discussion_r3328877692
##########
table/orphan_cleanup.go:
##########
@@ -411,35 +482,13 @@ func makeFileWalkFunc(fn func(path string, info
stdfs.FileInfo) error, pathTrans
}
}
-func identifyOrphanFiles(allFiles []string, referencedFiles map[string]bool,
cfg *orphanCleanupConfig) ([]string, error) {
- normalizedReferencedFiles := make(map[string]string)
- for refPath := range referencedFiles {
- normalizedPath := normalizeFilePathWithConfig(refPath, cfg)
- normalizedReferencedFiles[normalizedPath] = refPath
- // Also include the original path for direct lookup
- normalizedReferencedFiles[refPath] = refPath
- }
-
- var orphans []string
-
- for _, file := range allFiles {
- isOrphan, err := isFileOrphan(file, referencedFiles,
normalizedReferencedFiles, cfg)
- if err != nil {
- return nil, fmt.Errorf("failed to determine if file %s
is orphan: %w", file, err)
- }
-
- if isOrphan {
- orphans = append(orphans, file)
- }
- }
-
- return orphans, nil
-}
-
func isFileOrphan(file string, referencedFiles map[string]bool,
normalizedReferencedFiles map[string]string, cfg *orphanCleanupConfig) (bool,
error) {
normalizedFile := normalizeFilePathWithConfig(file, cfg)
- if referencedFiles[file] || referencedFiles[normalizedFile] {
+ if _, ok := referencedFiles[file]; ok {
Review Comment:
Good catch, didn't notice that 😀 I added both a comment and unit tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]