Пример #1
0
// For testing
func delLfsPath(path string) {
	path, err := zx.UseAbsPath(path)
	if err != nil {
		panic(err)
	}
	lfslk.Lock()
	defer lfslk.Unlock()
	addr := path
	if ofs, ok := lfs[addr]; ok {
		if cfs, ok := ofs.(io.Closer); ok {
			cfs.Close()
		}
	}
	delete(lfs, addr)
}
Пример #2
0
// Add the given (absolute) paths as valid paths to resolve lfs addresses.
// If the path is not ok, it's a panic.
// DirFs relies on this to resolve addresses of the form lfs!*
// and the longest path added is used.
// If fs is not given, a default zux tree is made for it and it's a panic if
// we fail to make fs.
func AddLfsPath(path string, fs zx.Fs) {
	path, err := zx.UseAbsPath(path)
	if err != nil {
		panic(err)
	}
	if fs == nil {
		fs, err = zux.NewZX(path)
		if err != nil {
			panic(err)
		}
	}
	lfslk.Lock()
	defer lfslk.Unlock()
	addr := path
	if ofs, ok := lfs[addr]; ok {
		if cfs, ok := ofs.(io.Closer); ok {
			cfs.Close()
		}
	}
	lfs[addr] = fs
}