summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/spf13/afero/memmap.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2023-08-05 20:43:19 +0200
committerGitHub <noreply@github.com>2023-08-05 20:43:19 +0200
commit56e7bd01ca09ad52b0c4f48f146a20a4f1b78696 (patch)
treeb1355645342667209263cbd355dc0b4254f1e8fe /vendor/github.com/spf13/afero/memmap.go
parent9459495484d6e06a3d46de64fccd8d06f7ccc72c (diff)
downloadmatterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.tar.gz
matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.tar.bz2
matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.zip
Update dependencies and remove old matterclient lib (#2067)HEADmaster
Diffstat (limited to 'vendor/github.com/spf13/afero/memmap.go')
-rw-r--r--vendor/github.com/spf13/afero/memmap.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/vendor/github.com/spf13/afero/memmap.go b/vendor/github.com/spf13/afero/memmap.go
index d06975e7..e6b7d70b 100644
--- a/vendor/github.com/spf13/afero/memmap.go
+++ b/vendor/github.com/spf13/afero/memmap.go
@@ -15,6 +15,7 @@ package afero
import (
"fmt"
+ "io"
"log"
"os"
"path/filepath"
@@ -43,7 +44,7 @@ func (m *MemMapFs) getData() map[string]*mem.FileData {
// Root should always exist, right?
// TODO: what about windows?
root := mem.CreateDir(FilePathSeparator)
- mem.SetMode(root, os.ModeDir|0755)
+ mem.SetMode(root, os.ModeDir|0o755)
m.data[FilePathSeparator] = root
})
return m.data
@@ -96,12 +97,12 @@ func (m *MemMapFs) registerWithParent(f *mem.FileData, perm os.FileMode) {
pdir := filepath.Dir(filepath.Clean(f.Name()))
err := m.lockfreeMkdir(pdir, perm)
if err != nil {
- //log.Println("Mkdir error:", err)
+ // log.Println("Mkdir error:", err)
return
}
parent, err = m.lockfreeOpen(pdir)
if err != nil {
- //log.Println("Open after Mkdir error:", err)
+ // log.Println("Open after Mkdir error:", err)
return
}
}
@@ -237,7 +238,7 @@ func (m *MemMapFs) OpenFile(name string, flag int, perm os.FileMode) (File, erro
file = mem.NewReadOnlyFileHandle(file.(*mem.File).Data())
}
if flag&os.O_APPEND > 0 {
- _, err = file.Seek(0, os.SEEK_END)
+ _, err = file.Seek(0, io.SeekEnd)
if err != nil {
file.Close()
return nil, err
@@ -319,6 +320,18 @@ func (m *MemMapFs) Rename(oldname, newname string) error {
} else {
return &os.PathError{Op: "rename", Path: oldname, Err: ErrFileNotFound}
}
+
+ for p, fileData := range m.getData() {
+ if strings.HasPrefix(p, oldname+FilePathSeparator) {
+ m.mu.RUnlock()
+ m.mu.Lock()
+ delete(m.getData(), p)
+ p := strings.Replace(p, oldname, newname, 1)
+ m.getData()[p] = fileData
+ m.mu.Unlock()
+ m.mu.RLock()
+ }
+ }
return nil
}