MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / OpenFS

Function OpenFS

internal/utils/bfs/fs.go:41–72  ·  view source on GitHub ↗

OpenFS 打开文件系统

(dir string, options *FSOptions)

Source from the content-addressed store, hash-verified

39
40// OpenFS 打开文件系统
41func OpenFS(dir string, options *FSOptions) (*FS, error) {
42 if !IsEnabled() {
43 return nil, errors.New("the fs only works under 64 bit system")
44 }
45
46 if options == nil {
47 options = DefaultFSOptions
48 } else {
49 options.EnsureDefaults()
50 }
51
52 var locker = fsutils.NewLocker(dir + "/fs")
53 err := locker.Lock()
54 if err != nil {
55 return nil, err
56 }
57
58 var fs = &FS{
59 dir: dir,
60 bMap: map[string]*BlocksFile{},
61 bList: linkedlist.NewList[string](),
62 bItemMap: map[string]*linkedlist.Item[string]{},
63 closingBMap: map[string]zero.Zero{},
64 closingBChan: make(chan *BlocksFile, 32),
65 mu: &sync.RWMutex{},
66 opt: options,
67 syncTicker: time.NewTicker(1 * time.Second),
68 locker: locker,
69 }
70 go fs.init()
71 return fs, nil
72}
73
74func (this *FS) init() {
75 go func() {

Callers 5

TestFS_OpenFileWriterFunction · 0.92
TestFS_OpenFileReaderFunction · 0.92
TestFS_ExistFileFunction · 0.92
TestFS_RemoveFileFunction · 0.92

Calls 4

initFunction · 0.92
IsEnabledFunction · 0.85
EnsureDefaultsMethod · 0.45
LockMethod · 0.45

Tested by 5

TestFS_OpenFileWriterFunction · 0.74
TestFS_OpenFileReaderFunction · 0.74
TestFS_ExistFileFunction · 0.74
TestFS_RemoveFileFunction · 0.74