mongo: remove drop dups option and return error if module exists (#913)

This commit is contained in:
Brent Pendergraft
2018-11-16 14:35:46 -06:00
committed by Manu Gupta
parent 132a75579b
commit 3b6aeb986e
2 changed files with 8 additions and 1 deletions
-1
View File
@@ -62,7 +62,6 @@ func (m *ModuleStore) initDatabase() error {
index := mgo.Index{
Key: []string{"base_url", "module", "version"},
Unique: true,
DropDups: true,
Background: true,
Sparse: true,
}
+8
View File
@@ -16,6 +16,14 @@ func (s *ModuleStore) Save(ctx context.Context, module, version string, mod []by
ctx, span := observ.StartSpan(ctx, op.String())
defer span.End()
exists, err := s.Exists(ctx, module, version)
if err != nil {
return errors.E(op, err, errors.M(module), errors.V(version))
}
if exists {
return errors.E(op, "already exists", errors.M(module), errors.V(version), errors.KindAlreadyExists)
}
zipName := s.gridFileName(module, version)
fs := s.s.DB(s.d).GridFS("fs")
f, err := fs.Create(zipName)