本文整理汇总了Golang中github.com/ipfs/go-ipfs/thirdparty/dir.Writable函数的典型用法代码示例。如果您正苦于以下问题:Golang Writable函数的具体用法?Golang Writable怎么用?Golang Writable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Writable函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: initDefaultDatastore
func initDefaultDatastore(repoPath string, conf *config.Config) error {
// The actual datastore contents are initialized lazily when Opened.
// During Init, we merely check that the directory is writeable.
leveldbPath := path.Join(repoPath, leveldbDirectory)
if err := dir.Writable(leveldbPath); err != nil {
return fmt.Errorf("datastore: %s", err)
}
flatfsPath := path.Join(repoPath, flatfsDirectory)
if err := dir.Writable(flatfsPath); err != nil {
return fmt.Errorf("datastore: %s", err)
}
return nil
}
开发者ID:qnib,项目名称:go-ipfs,代码行数:14,代码来源:defaultds.go
示例2: Init
// Init initializes a new FSRepo at the given path with the provided config.
// TODO add support for custom datastores.
func Init(repoPath string, conf *config.Config) error {
// packageLock must be held to ensure that the repo is not initialized more
// than once.
packageLock.Lock()
defer packageLock.Unlock()
if isInitializedUnsynced(repoPath) {
return nil
}
if err := initConfig(repoPath, conf); err != nil {
return err
}
if err := initDefaultDatastore(repoPath, conf); err != nil {
return err
}
if err := dir.Writable(filepath.Join(repoPath, "logs")); err != nil {
return err
}
if err := mfsr.RepoPath(repoPath).WriteVersion(RepoVersion); err != nil {
return err
}
return nil
}
开发者ID:eminence,项目名称:go-ipfs,代码行数:31,代码来源:fsrepo.go
示例3: open
func open(repoPath string) (repo.Repo, error) {
packageLock.Lock()
defer packageLock.Unlock()
r, err := newFSRepo(repoPath)
if err != nil {
return nil, err
}
// Check if its initialized
if err := checkInitialized(r.path); err != nil {
return nil, err
}
r.lockfile, err = lockfile.Lock(r.path)
if err != nil {
return nil, err
}
keepLocked := false
defer func() {
// unlock on error, leave it locked on success
if !keepLocked {
r.lockfile.Close()
}
}()
// Check version, and error out if not matching
ver, err := mfsr.RepoPath(r.path).Version()
if err != nil {
if os.IsNotExist(err) {
return nil, ErrNoVersion
}
return nil, err
}
if ver != RepoVersion {
return nil, fmt.Errorf(errIncorrectRepoFmt, ver, RepoVersion)
}
// check repo path, then check all constituent parts.
if err := dir.Writable(r.path); err != nil {
return nil, err
}
if err := r.openConfig(); err != nil {
return nil, err
}
if err := r.openDatastore(); err != nil {
return nil, err
}
// setup eventlogger
configureEventLoggerAtRepoPath(r.config, r.path)
keepLocked = true
return r, nil
}
开发者ID:heems,项目名称:go-ipfs,代码行数:58,代码来源:fsrepo.go
示例4: open
func open(repoPath string) (repo.Repo, error) {
packageLock.Lock()
defer packageLock.Unlock()
r, err := newFSRepo(repoPath)
if err != nil {
return nil, err
}
// Check if its initialized
if err := checkInitialized(r.path); err != nil {
return nil, err
}
r.lockfile, err = lockfile.Lock(r.path)
if err != nil {
return nil, err
}
keepLocked := false
defer func() {
// unlock on error, leave it locked on success
if !keepLocked {
r.lockfile.Close()
}
}()
// Check version, and error out if not matching
ver, err := mfsr.RepoPath(r.path).Version()
if err != nil {
if os.IsNotExist(err) {
return nil, ErrNoVersion
}
return nil, err
}
if RepoVersion > ver {
return nil, ErrNeedMigration
} else if ver > RepoVersion {
// program version too low for existing repo
return nil, fmt.Errorf(programTooLowMessage, RepoVersion, ver)
}
// check repo path, then check all constituent parts.
if err := dir.Writable(r.path); err != nil {
return nil, err
}
if err := r.openConfig(); err != nil {
return nil, err
}
if err := r.openDatastore(); err != nil {
return nil, err
}
keepLocked = true
return r, nil
}
开发者ID:qnib,项目名称:go-ipfs,代码行数:58,代码来源:fsrepo.go
示例5: Init
// Init initializes a new FSRepo at the given path with the provided config.
// TODO add support for custom datastores.
func Init(repoPath string, conf *config.Config) error {
// packageLock must be held to ensure that the repo is not initialized more
// than once.
packageLock.Lock()
defer packageLock.Unlock()
if isInitializedUnsynced(repoPath) {
return nil
}
if err := initConfig(repoPath, conf); err != nil {
return err
}
// The actual datastore contents are initialized lazily when Opened.
// During Init, we merely check that the directory is writeable.
leveldbPath := path.Join(repoPath, leveldbDirectory)
if err := dir.Writable(leveldbPath); err != nil {
return fmt.Errorf("datastore: %s", err)
}
flatfsPath := path.Join(repoPath, flatfsDirectory)
if err := dir.Writable(flatfsPath); err != nil {
return fmt.Errorf("datastore: %s", err)
}
if err := dir.Writable(path.Join(repoPath, "logs")); err != nil {
return err
}
if err := mfsr.RepoPath(repoPath).WriteVersion(RepoVersion); err != nil {
return err
}
return nil
}
开发者ID:heems,项目名称:go-ipfs,代码行数:39,代码来源:fsrepo.go
注:本文中的github.com/ipfs/go-ipfs/thirdparty/dir.Writable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论