Skip to content

Commit

Permalink
introduce map setter
Browse files Browse the repository at this point in the history
  • Loading branch information
jxsl13 committed Jul 16, 2024
1 parent 983dbdf commit 3f54724
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions backupfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@ func (fsys *BackupFS) Map() map[string]fs.FileInfo {
return m
}

func (fsys *BackupFS) SetMap(metadata map[string]fs.FileInfo) {

// clone state
m := make(map[string]fs.FileInfo, len(metadata))
for path, info := range metadata {
if info == nil {
m[path] = nil
continue
}
m[path] = info
}

fsys.mu.Lock()
defer fsys.mu.Unlock()

fsys.baseInfos = m
}

func toFInfo(path string, fi fs.FileInfo) *fInfo {
return &fInfo{
FileName: filepath.ToSlash(path),
Expand Down

0 comments on commit 3f54724

Please sign in to comment.