Delete will delete the object.
(name string)
| 709 | |
| 710 | // Delete will delete the object. |
| 711 | func (obs *obs) Delete(name string) error { |
| 712 | // Grab meta info. |
| 713 | info, err := obs.GetInfo(name, GetObjectInfoShowDeleted()) |
| 714 | if err != nil { |
| 715 | return err |
| 716 | } |
| 717 | if info.NUID == _EMPTY_ { |
| 718 | return ErrBadObjectMeta |
| 719 | } |
| 720 | |
| 721 | // Place a rollup delete marker and publish the info |
| 722 | info.Deleted = true |
| 723 | info.Size, info.Chunks, info.Digest = 0, 0, _EMPTY_ |
| 724 | |
| 725 | if err = publishMeta(info, obs.js); err != nil { |
| 726 | return err |
| 727 | } |
| 728 | |
| 729 | // Purge chunks for the object. |
| 730 | chunkSubj := fmt.Sprintf(objChunksPreTmpl, obs.name, info.NUID) |
| 731 | return obs.js.purgeStream(obs.stream, &StreamPurgeRequest{Subject: chunkSubj}) |
| 732 | } |
| 733 | |
| 734 | func publishMeta(info *ObjectInfo, js JetStreamContext) error { |
| 735 | // marshal the object into json, don't store an actual time |
nothing calls this directly
no test coverage detected