localdisk: add IsDir

Change-Id: I98748d6cb8ff650e0369ef0518eeeefce73f0354
This commit is contained in:
Brad Fitzpatrick 2014-02-07 10:45:43 -08:00
parent 254239c379
commit 9a9da7196b
1 changed files with 10 additions and 0 deletions

View File

@ -34,12 +34,14 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"sync"
"camlistore.org/pkg/blob"
"camlistore.org/pkg/blobserver"
"camlistore.org/pkg/blobserver/local"
"camlistore.org/pkg/jsonconfig"
"camlistore.org/pkg/osutil"
"camlistore.org/pkg/types"
)
@ -56,6 +58,14 @@ type DiskStorage struct {
gen *local.Generationer
}
// IsDir reports whether root is a localdisk (file-per-blob) storage directory.
func IsDir(root string) (bool, error) {
if osutil.DirExists(filepath.Join(root, blob.RefFromString("").HashName())) {
return true, nil
}
return false, nil
}
// New returns a new local disk storage implementation at the provided
// root directory, which must already exist.
func New(root string) (*DiskStorage, error) {