diff options
author | Nick White <git@njw.name> | 2021-01-26 14:56:10 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-01-26 14:56:10 +0000 |
commit | 5c3cee66a90ce6ef87e125b3bf011a6903d38083 (patch) | |
tree | be1347c79389b232150227bd8489db3fabb415ac /local.go | |
parent | 54150b54cd06e3deba44e73b151070b74a4d8e76 (diff) |
Make ListObjectsWithMeta generic again and create a specialised ListObjectWithMeta for single file listing, so we can still be as fast, but do not have a misleading api
Diffstat (limited to 'local.go')
-rw-r--r-- | local.go | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -159,6 +159,17 @@ func (a *LocalConn) ListObjectsWithMeta(bucket string, prefix string) ([]ObjMeta return list, err } +func (a *LocalConn) ListObjectWithMeta(bucket string, prefix string) (ObjMeta, error) { + list, err := a.ListObjectsWithMeta(bucket, prefix) + if err != nil { + return ObjMeta{}, err + } + if len(list) == 0 { + return ObjMeta{}, fmt.Errorf("No object found for %s", prefix) + } + return list[0], nil +} + // AddToQueue adds a message to a queue func (a *LocalConn) AddToQueue(url string, msg string) error { f, err := os.OpenFile(filepath.Join(a.TempDir, url), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) |