chore(deps): bump github.com/spf13/afero from 1.9.5 to 1.10.0 (#2758)
Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.9.5 to 1.10.0. - [Release notes](https://github.com/spf13/afero/releases) - [Commits](https://github.com/spf13/afero/compare/v1.9.5...v1.10.0) --- updated-dependencies: - dependency-name: github.com/spf13/afero dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
6574ff8037
commit
7aa04ffc5a
2
go.mod
2
go.mod
|
|
@ -31,7 +31,7 @@ require (
|
||||||
github.com/otiai10/copy v1.12.0
|
github.com/otiai10/copy v1.12.0
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/spf13/afero v1.9.5
|
github.com/spf13/afero v1.10.0
|
||||||
github.com/spf13/cobra v1.7.0
|
github.com/spf13/cobra v1.7.0
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
golang.org/x/net v0.15.0
|
golang.org/x/net v0.15.0
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -607,8 +607,8 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1
|
||||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||||
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
|
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
|
||||||
github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM=
|
github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY=
|
||||||
github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ=
|
github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ=
|
||||||
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
||||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//go:build aix || darwin || openbsd || freebsd || netbsd || dragonfly
|
//go:build aix || darwin || openbsd || freebsd || netbsd || dragonfly || zos
|
||||||
// +build aix darwin openbsd freebsd netbsd dragonfly
|
// +build aix darwin openbsd freebsd netbsd dragonfly zos
|
||||||
|
|
||||||
package afero
|
package afero
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//go:build !darwin && !openbsd && !freebsd && !dragonfly && !netbsd && !aix
|
//go:build !darwin && !openbsd && !freebsd && !dragonfly && !netbsd && !aix && !zos
|
||||||
// +build !darwin,!openbsd,!freebsd,!dragonfly,!netbsd,!aix
|
// +build !darwin,!openbsd,!freebsd,!dragonfly,!netbsd,!aix,!zos
|
||||||
|
|
||||||
package afero
|
package afero
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,12 @@ package afero
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -88,6 +91,24 @@ func (m *MemMapFs) findParent(f *mem.FileData) *mem.FileData {
|
||||||
return pfile
|
return pfile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MemMapFs) findDescendants(name string) []*mem.FileData {
|
||||||
|
fData := m.getData()
|
||||||
|
descendants := make([]*mem.FileData, 0, len(fData))
|
||||||
|
for p, dFile := range fData {
|
||||||
|
if strings.HasPrefix(p, name+FilePathSeparator) {
|
||||||
|
descendants = append(descendants, dFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(descendants, func(i, j int) bool {
|
||||||
|
cur := len(strings.Split(descendants[i].Name(), FilePathSeparator))
|
||||||
|
next := len(strings.Split(descendants[j].Name(), FilePathSeparator))
|
||||||
|
return cur < next
|
||||||
|
})
|
||||||
|
|
||||||
|
return descendants
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MemMapFs) registerWithParent(f *mem.FileData, perm os.FileMode) {
|
func (m *MemMapFs) registerWithParent(f *mem.FileData, perm os.FileMode) {
|
||||||
if f == nil {
|
if f == nil {
|
||||||
return
|
return
|
||||||
|
|
@ -309,29 +330,51 @@ func (m *MemMapFs) Rename(oldname, newname string) error {
|
||||||
if _, ok := m.getData()[oldname]; ok {
|
if _, ok := m.getData()[oldname]; ok {
|
||||||
m.mu.RUnlock()
|
m.mu.RUnlock()
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
m.unRegisterWithParent(oldname)
|
err := m.unRegisterWithParent(oldname)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
fileData := m.getData()[oldname]
|
fileData := m.getData()[oldname]
|
||||||
delete(m.getData(), oldname)
|
|
||||||
mem.ChangeFileName(fileData, newname)
|
mem.ChangeFileName(fileData, newname)
|
||||||
m.getData()[newname] = fileData
|
m.getData()[newname] = fileData
|
||||||
|
|
||||||
|
err = m.renameDescendants(oldname, newname)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(m.getData(), oldname)
|
||||||
|
|
||||||
m.registerWithParent(fileData, 0)
|
m.registerWithParent(fileData, 0)
|
||||||
m.mu.Unlock()
|
m.mu.Unlock()
|
||||||
m.mu.RLock()
|
m.mu.RLock()
|
||||||
} else {
|
} else {
|
||||||
return &os.PathError{Op: "rename", Path: oldname, Err: ErrFileNotFound}
|
return &os.PathError{Op: "rename", Path: oldname, Err: ErrFileNotFound}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
for p, fileData := range m.getData() {
|
func (m *MemMapFs) renameDescendants(oldname, newname string) error {
|
||||||
if strings.HasPrefix(p, oldname+FilePathSeparator) {
|
descendants := m.findDescendants(oldname)
|
||||||
m.mu.RUnlock()
|
removes := make([]string, 0, len(descendants))
|
||||||
m.mu.Lock()
|
for _, desc := range descendants {
|
||||||
delete(m.getData(), p)
|
descNewName := strings.Replace(desc.Name(), oldname, newname, 1)
|
||||||
p := strings.Replace(p, oldname, newname, 1)
|
err := m.unRegisterWithParent(desc.Name())
|
||||||
m.getData()[p] = fileData
|
if err != nil {
|
||||||
m.mu.Unlock()
|
return err
|
||||||
m.mu.RLock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removes = append(removes, desc.Name())
|
||||||
|
mem.ChangeFileName(desc, descNewName)
|
||||||
|
m.getData()[descNewName] = desc
|
||||||
|
|
||||||
|
m.registerWithParent(desc, 0)
|
||||||
}
|
}
|
||||||
|
for _, r := range removes {
|
||||||
|
delete(m.getData(), r)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -798,7 +798,7 @@ github.com/sirupsen/logrus
|
||||||
# github.com/skeema/knownhosts v1.2.0
|
# github.com/skeema/knownhosts v1.2.0
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
github.com/skeema/knownhosts
|
github.com/skeema/knownhosts
|
||||||
# github.com/spf13/afero v1.9.5
|
# github.com/spf13/afero v1.10.0
|
||||||
## explicit; go 1.16
|
## explicit; go 1.16
|
||||||
github.com/spf13/afero
|
github.com/spf13/afero
|
||||||
github.com/spf13/afero/internal/common
|
github.com/spf13/afero/internal/common
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue