Example #1
0
// GetAvailableParts returns an io.ReadCloser that will read the specified part of the object.
func (s *Storage) GetAvailableParts(oid *types.ObjectID) ([]*types.ObjectIndex, error) {
	var result = make([]*types.ObjectIndex, 0, len(s.Parts))
	if obj, ok := s.Parts[oid.Hash()]; ok {
		for partNum := range obj {
			result = append(result,
				&types.ObjectIndex{
					ObjID: oid,
					Part:  partNum,
				})
		}
	}
	return result, os.ErrNotExist
}
Example #2
0
// Discard removes the object and its metadata.
func (s *Storage) Discard(id *types.ObjectID) error {
	if _, ok := s.Objects[id.Hash()]; !ok {
		return os.ErrNotExist
	}
	delete(s.Objects, id.Hash())
	delete(s.Parts, id.Hash())

	return nil
}
Example #3
0
// GetMetadata returns the metadata for this object, if present.
func (s *Storage) GetMetadata(id *types.ObjectID) (*types.ObjectMetadata, error) {
	if obj, ok := s.Objects[id.Hash()]; ok {
		return obj, nil
	}
	return nil, os.ErrNotExist
}