RemoveStore remove store directory
(path string)
| 18 | |
| 19 | // RemoveStore remove store directory |
| 20 | func RemoveStore(path string) error { |
| 21 | var errNotStoreDirectory = errors.New("not store directory") |
| 22 | |
| 23 | if strings.HasSuffix(path, StoreSuffix) { |
| 24 | _, err := os.Stat(path) |
| 25 | if err != nil { |
| 26 | if os.IsNotExist(err) { |
| 27 | return nil |
| 28 | } |
| 29 | return err |
| 30 | } |
| 31 | |
| 32 | // validate store |
| 33 | { |
| 34 | _, err = os.Stat(path + "/CURRENT") |
| 35 | if err != nil { |
| 36 | return errNotStoreDirectory |
| 37 | } |
| 38 | } |
| 39 | { |
| 40 | _, err = os.Stat(path + "/LOCK") |
| 41 | if err != nil { |
| 42 | return errNotStoreDirectory |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | return os.RemoveAll(path) |
| 47 | } |
| 48 | |
| 49 | return errNotStoreDirectory |
| 50 | } |