From 9a9da7196bfde7b38747f872a8154ac07d00c724 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 7 Feb 2014 10:45:43 -0800 Subject: [PATCH] localdisk: add IsDir Change-Id: I98748d6cb8ff650e0369ef0518eeeefce73f0354 --- pkg/blobserver/localdisk/localdisk.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/blobserver/localdisk/localdisk.go b/pkg/blobserver/localdisk/localdisk.go index d9d16e657..f3056878c 100644 --- a/pkg/blobserver/localdisk/localdisk.go +++ b/pkg/blobserver/localdisk/localdisk.go @@ -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) {