Skip to content

Commit

Permalink
fix(core.DatasetRequests.Delete): restore dataset delete method
Browse files Browse the repository at this point in the history
so, uh, dataset deletion has been broken for a while. This brings it back.

closes #89
  • Loading branch information
b5 committed Nov 8, 2017
1 parent 7858ba7 commit 54abed8
Showing 1 changed file with 29 additions and 35 deletions.
64 changes: 29 additions & 35 deletions core/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,41 +229,35 @@ type DeleteParams struct {
Name string
}

func (r *DatasetRequests) Delete(p *DeleteParams, ok *bool) error {
// TODO - restore
// if p.Path.String() == "" {
// r.
// }
// TODO - unpin resource and data
// resource := p.Dataset.Resource
// npath, err := r.repo.GetPath(p.Name)

// err := r.repo.DeleteName(p.Name)
// ns, err := r.repo.Namespace()
// if err != nil {
// return err
// }
// if p.Name == "" && p.Path.String() != "" {
// for name, val := range ns {
// if val.Equal(p.Path) {
// p.Name = name
// }
// }
// }

// if p.Name == "" {
// return fmt.Errorf("couldn't find dataset: %s", p.Path.String())
// } else if ns[p.Name] == datastore.NewKey("") {
// return fmt.Errorf("couldn't find dataset: %s", p.Name)
// }

// delete(ns, p.Name)
// if err := r.repo.SaveNamespace(ns); err != nil {
// return err
// }
// *ok = true
// return nil
return fmt.Errorf("delete dataset not yet finished")
func (r *DatasetRequests) Delete(p *DeleteParams, ok *bool) (err error) {
path := p.Path
if path == "" {
path, err = r.repo.GetPath(name)
if err != nil {
return
}
}

name := p.Name
if name == "" {
name, err = r.repo.GetName(path)
if err != nil {
return
}
}

if pinner, ok := r.store.(cafs.Pinner); ok {
if err = pinner.Unpin(path, true); err != nil {
return
}
}

if err = r.repo.DeleteName(name); err != nil {
return
}

*ok = true
return nil
}

type StructuredDataParams struct {
Expand Down

0 comments on commit 54abed8

Please sign in to comment.