]> Cypherpunks.ru repositories - goredo.git/blobdiff - cleanup.go
Use more efficient ReadDir instead of Readdir
[goredo.git] / cleanup.go
index bdd295dd3ee6689f8ed93af330f4f30b7de1303a..d0b508d44201a7645717f77192b653cd5f4f30ef 100644 (file)
@@ -55,7 +55,7 @@ func redoDirClean(root, what string) error {
        }
        defer dir.Close()
        for {
-               fis, err := dir.Readdir(1 << 10)
+               entries, err := dir.ReadDir(1 << 10)
                if err != nil {
                        if err == io.EOF {
                                break
@@ -63,12 +63,12 @@ func redoDirClean(root, what string) error {
                        return err
                }
                var pth string
-               for _, fi := range fis {
-                       pth = cwdMustRel(root, fi.Name())
+               for _, entry := range entries {
+                       pth = cwdMustRel(root, entry.Name())
                        switch what {
                        case CleanupLog:
-                               if strings.HasSuffix(fi.Name(), LogSuffix) ||
-                                       strings.HasSuffix(fi.Name(), LogRecSuffix) {
+                               if strings.HasSuffix(entry.Name(), LogSuffix) ||
+                                       strings.HasSuffix(entry.Name(), LogRecSuffix) {
                                        fmt.Println(pth)
                                        if !*DryRun {
                                                if err = os.Remove(pth); err != nil {
@@ -77,7 +77,7 @@ func redoDirClean(root, what string) error {
                                        }
                                }
                        case CleanupLock:
-                               if strings.HasSuffix(fi.Name(), LockSuffix) {
+                               if strings.HasSuffix(entry.Name(), LockSuffix) {
                                        fmt.Println(pth)
                                        if !*DryRun {
                                                if err = os.Remove(pth); err != nil {
@@ -86,7 +86,7 @@ func redoDirClean(root, what string) error {
                                        }
                                }
                        case CleanupTmp:
-                               if strings.HasPrefix(fi.Name(), TmpPrefix) {
+                               if strings.HasPrefix(entry.Name(), TmpPrefix) {
                                        fmt.Println(pth)
                                        if !*DryRun {
                                                if err = os.Remove(pth); err != nil {
@@ -113,18 +113,18 @@ func cleanupWalker(root, what string) error {
        }
        defer dir.Close()
        for {
-               fis, err := dir.Readdir(1 << 10)
+               entries, err := dir.ReadDir(1 << 10)
                if err != nil {
                        if err == io.EOF {
                                break
                        }
                        return err
                }
-               for _, fi := range fis {
-                       pth := path.Join(root, fi.Name())
-                       pthRel := cwdMustRel(root, fi.Name())
-                       if fi.IsDir() {
-                               if fi.Name() == RedoDir {
+               for _, entry := range entries {
+                       pth := path.Join(root, entry.Name())
+                       pthRel := cwdMustRel(root, entry.Name())
+                       if entry.IsDir() {
+                               if entry.Name() == RedoDir {
                                        if what == CleanupFull {
                                                fmt.Println(pthRel)
                                                if !*DryRun {
@@ -134,7 +134,7 @@ func cleanupWalker(root, what string) error {
                                                err = redoDirClean(pth, what)
                                        }
                                } else if (what == CleanupTmp || what == CleanupFull) &&
-                                       strings.HasPrefix(fi.Name(), TmpPrefix) {
+                                       strings.HasPrefix(entry.Name(), TmpPrefix) {
                                        fmt.Println(pthRel)
                                        if !*DryRun {
                                                err = os.RemoveAll(pth)
@@ -148,7 +148,7 @@ func cleanupWalker(root, what string) error {
                                continue
                        }
                        if (what == CleanupTmp || what == CleanupFull) &&
-                               strings.HasPrefix(fi.Name(), TmpPrefix) {
+                               strings.HasPrefix(entry.Name(), TmpPrefix) {
                                fmt.Println(pthRel)
                                if !*DryRun {
                                        if err = os.Remove(pth); err != nil {