fs: clean up helper functions

This commit is contained in:
Michael Eischer
2024-07-21 14:40:33 +02:00
parent fc549c9462
commit 0ddb4441d7
5 changed files with 5 additions and 38 deletions

View File

@@ -446,7 +446,7 @@ func (arch *Archiver) save(ctx context.Context, snPath, target string, previous
}
switch {
case fs.IsRegularFile(fi):
case fi.Mode().IsRegular():
debug.Log(" %v regular file", target)
// check if the file has not changed before performing a fopen operation (more expensive, specially
@@ -505,7 +505,7 @@ func (arch *Archiver) save(ctx context.Context, snPath, target string, previous
}
// make sure it's still a file
if !fs.IsRegularFile(fi) {
if !fi.Mode().IsRegular() {
err = errors.Errorf("file %v changed type, refusing to archive", fi.Name())
_ = file.Close()
err = arch.error(abstarget, err)

View File

@@ -169,7 +169,7 @@ func TestEnsureFiles(t testing.TB, target string, dir TestDir) {
}
return nil
case TestFile:
if !fs.IsRegularFile(fi) {
if !fi.Mode().IsRegular() {
t.Errorf("is not a regular file: %v", path)
return nil
}
@@ -208,7 +208,7 @@ func TestEnsureFiles(t testing.TB, target string, dir TestDir) {
})
// then, traverse the directory again, looking for additional files
err := fs.Walk(target, func(path string, fi os.FileInfo, err error) error {
err := filepath.Walk(target, func(path string, fi os.FileInfo, err error) error {
if err != nil {
return err
}

View File

@@ -122,7 +122,7 @@ func TestTestCreateFiles(t *testing.T) {
switch node := item.(type) {
case TestFile:
if !fs.IsRegularFile(fi) {
if !fi.Mode().IsRegular() {
t.Errorf("is not regular file: %v", name)
continue
}