Skip to content

Commit

Permalink
add nil check to Map
Browse files Browse the repository at this point in the history
  • Loading branch information
jxsl13 committed Jul 16, 2024
1 parent 3f54724 commit 4ef7787
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backupfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,17 @@ func (fsys *BackupFS) Rollback() error {
return nil
}

func (fsys *BackupFS) Map() map[string]fs.FileInfo {
func (fsys *BackupFS) Map() (metadata map[string]fs.FileInfo) {
fsys.mu.Lock()
defer fsys.mu.Unlock()

m := make(map[string]fs.FileInfo, len(fsys.baseInfos))
for path, info := range fsys.baseInfos {
if info == nil {
m[path] = nil // nil w/o type information is needed here
continue
}

m[path] = toFInfo(path, info)
}
return m
Expand Down

0 comments on commit 4ef7787

Please sign in to comment.