aboutsummaryrefslogtreecommitdiffstats
path: root/store.go
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2012-04-18 22:07:52 -0400
committerbnewbold <bnewbold@robocracy.org>2012-04-18 22:07:52 -0400
commitb85e202511ea821c773f5eeb305ff71f040fc098 (patch)
tree609c05bf13aeb1bf6ee458f58d600d00d4661d87 /store.go
parent6023bb2fe3759dc01e608ed056e843b1f731acf0 (diff)
downloadbommom-b85e202511ea821c773f5eeb305ff71f040fc098.tar.gz
bommom-b85e202511ea821c773f5eeb305ff71f040fc098.zip
tweaks, basic loading
Diffstat (limited to 'store.go')
-rw-r--r--store.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/store.go b/store.go
index d08deaa..343cd9e 100644
--- a/store.go
+++ b/store.go
@@ -129,8 +129,21 @@ func (jfbs *JSONFileBomStore) listBomsForUser(user ShortName) ([]BomStub, error)
}
func (jfbs *JSONFileBomStore) Persist(bs *BomStub, b *Bom, version ShortName) error {
+
+ if err := bs.Validate(); err != nil {
+ return err
+ }
+ if err := b.Validate(); err != nil {
+ return err
+ }
+
b_fpath := jfbs.Rootfpath + "/" + string(bs.Owner) + "/" + string(bs.Name) + "/" + string(version) + ".json"
bs_fpath := jfbs.Rootfpath + "/" + string(bs.Owner) + "/" + string(bs.Name) + "/_meta.json"
+
+ if f, err := os.Open(b_fpath); err == nil {
+ f.Close()
+ return Error("bom with same owner, name, and version already exists")
+ }
if err := writeJsonBomStub(bs_fpath, bs); err != nil {
log.Fatal(err)
}