//TODO delete all files func (s *Source) Delete() error { _, err := engine.Id(s.Id).Delete(new(Source)) if err != nil { return err } else { if util.IsExist(s.Path) { return os.RemoveAll(s.Path) } else { return nil } } }
func (p *Problem) Delete() error { _, err := engine.Id(p.Id).Delete(new(Problem)) if err != nil { return err } ip := p.InputTestPath i := strings.Index(ip, "/inputTest") if i > len(ip) { log.Println("index out of range") log.Println(i, len(ip)) return errors.New("index out of range") } else { dir := ip[:i] if util.IsExist(dir) { return os.RemoveAll(ip[:i]) } else { return nil } } }