diff options
author | bnewbold <bnewbold@robocracy.org> | 2012-04-18 22:07:52 -0400 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2012-04-18 22:07:52 -0400 |
commit | b85e202511ea821c773f5eeb305ff71f040fc098 (patch) | |
tree | 609c05bf13aeb1bf6ee458f58d600d00d4661d87 /store.go | |
parent | 6023bb2fe3759dc01e608ed056e843b1f731acf0 (diff) | |
download | bommom-b85e202511ea821c773f5eeb305ff71f040fc098.tar.gz bommom-b85e202511ea821c773f5eeb305ff71f040fc098.zip |
tweaks, basic loading
Diffstat (limited to 'store.go')
-rw-r--r-- | store.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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) } |