RemoveObject will delete a single cached object and all the chunks which belong to it
(fp string)
| 408 | |
| 409 | // RemoveObject will delete a single cached object and all the chunks which belong to it |
| 410 | func (b *Persistent) RemoveObject(fp string) error { |
| 411 | parentDir, objName := path.Split(fp) |
| 412 | return b.db.Update(func(tx *bolt.Tx) error { |
| 413 | bucket := b.getBucket(cleanPath(parentDir), false, tx) |
| 414 | if bucket == nil { |
| 415 | return fmt.Errorf("couldn't open parent bucket for %v", cleanPath(parentDir)) |
| 416 | } |
| 417 | err := bucket.Delete([]byte(cleanPath(objName))) |
| 418 | if err != nil { |
| 419 | fs.Debugf(fp, "couldn't delete obj from storage: %v", err) |
| 420 | } |
| 421 | // delete chunks on disk |
| 422 | // safe to ignore as the file might not have been open |
| 423 | _ = os.RemoveAll(path.Join(b.dataPath, fp)) |
| 424 | return nil |
| 425 | }) |
| 426 | } |
| 427 | |
| 428 | // ExpireObject will flush an Object and all its data if desired |
| 429 | func (b *Persistent) ExpireObject(co *Object, withData bool) error { |