• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 13423774416

19 Feb 2025 10:39PM UTC coverage: 49.338% (-9.5%) from 58.794%
13423774416

Pull #9484

github

Abdulkbk
lnutils: add createdir util function

This utility function replaces repetitive logic patterns
throughout LND.
Pull Request #9484: lnutils: add createDir util function

0 of 13 new or added lines in 1 file covered. (0.0%)

27149 existing lines in 431 files now uncovered.

100732 of 204168 relevant lines covered (49.34%)

1.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lnutils/fs.go
1
package lnutils
2

3
import (
4
        "fmt"
5
        "os"
6
)
7

8
// CreateDir creates a directory if it doesn't exist and also handles
9
// symlink-related errors with user-friendly messages. It creates all necessary
10
// parent directories with the specified permissions.
NEW
11
func CreateDir(dir string, perm os.FileMode) error {
×
NEW
12
        err := os.MkdirAll(dir, perm)
×
NEW
13
        if err == nil {
×
NEW
14
                return nil
×
NEW
15
        }
×
16
        // Show a nicer error message if it's because a symlink
17
        // is linked to a directory that does not exist
18
        // (probably because it's not mounted).
NEW
19
        if e, ok := err.(*os.PathError); ok && os.IsExist(err) {
×
NEW
20
                link, lerr := os.Readlink(e.Path)
×
NEW
21
                if lerr == nil {
×
NEW
22
                        return fmt.Errorf("is symlink %s -> %s "+
×
NEW
23
                                "mounted?", e.Path, link)
×
NEW
24
                }
×
25
        }
26

NEW
27
        return fmt.Errorf("failed to create directory '%s': %v",
×
NEW
28
                dir, err)
×
29
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc