Skip to content

Commit

Permalink
fix list with details to return the same thing
Browse files Browse the repository at this point in the history
  • Loading branch information
Akopti8 committed Jan 31, 2024
1 parent 921f31f commit be3b547
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions blobstore/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ func (bh *BlobHandler) HandleListByPrefixWithDetail(c echo.Context) error {
// Handle directories (common prefixes)
dir := ListResult{
ID: count,
Bucket: bucket,
Name: filepath.Base(strings.TrimSuffix(*cp.Prefix, "/")),
Name: filepath.Base(*cp.Prefix),
Size: "",
Path: *cp.Prefix,
Type: "",
IsDir: true,
Modified: time.Time{}, // Directory might not have a modified time
ModifiedBy: "", // Information might not be available
ModifiedBy: "",
}
results = append(results, dir)
count++
Expand All @@ -167,14 +167,13 @@ func (bh *BlobHandler) HandleListByPrefixWithDetail(c echo.Context) error {
// Handle files
file := ListResult{
ID: count,
Bucket: bucket,
Name: filepath.Base(*object.Key),
Size: strconv.FormatInt(*object.Size, 10),
Path: *object.Key,
Path: filepath.Dir(*object.Key),
Type: filepath.Ext(*object.Key),
IsDir: false,
Modified: *object.LastModified,
ModifiedBy: "", // Information might not be available
ModifiedBy: "",
}
results = append(results, file)
count++
Expand Down
2 changes: 1 addition & 1 deletion blobstore/object_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (bh *BlobHandler) HandleObjectContents(c echo.Context) error {
if err != nil {
errMsg := fmt.Errorf("error fetching object's content: %s", err.Error())
log.Error(errMsg.Error())
if strings.Contains(err.Error(), "object") {
if strings.Contains(err.Error(), "not found") {
return c.JSON(http.StatusNotFound, errMsg.Error())
} else {
return c.JSON(http.StatusInternalServerError, errMsg.Error())
Expand Down

0 comments on commit be3b547

Please sign in to comment.