Skip to content

Conversation

@louiscb
Copy link
Contributor

@louiscb louiscb commented Apr 4, 2025

We thought to spread out the changes of my original pr into several.

This will use the is_latest tag, and also passes in the prefix so that we only lookup the correct object instead of listing all objects in the whole bucket.

I tested and can see the even buckets that are not versioned will return is_latest for an object. e.g for appmonet.com bucket :

contents #=> [
  %{
    owner: %{
      id: "a59edb577d3ca9ca18794e866cc0c131d4bb9232f58dc8be4c4d634f9ff784dc",
      display_name: "nick.jacob"
    },
    size: "17100",
    key: "index.html",
    last_modified: "2017-04-01T14:20:53.000Z",
    etag: "\"adf6d5ab13452ec30d7556caaf49fab8\"",
    version_id: "null",
    is_latest: "true"
  }
]

@louiscb louiscb requested a review from sneako April 4, 2025 10:34

defp find_latest([_ | _] = contents, key) do
defp find_latest([_ | _] = contents) do
dbg contents
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dbg contents

end

defp find_latest(_, _), do: {:error, :not_found}
defp find_latest(_), do: {:error, :not_found}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you matching on this :not_found somewhere? Otherwise I think we should either:

  • use a more descriptive string, something like "object @ #{key} was not found"
  • introduce an Exception that will produce a similar message to the string above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we match on it already when we call find_latest:

      {:error, :not_found} ->
        {:error, "could not find s3://#{state.bucket}/#{state.key}"}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect

Copy link
Member

@sneako sneako left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please just increment the patch version? then we can merge and publish this

@louiscb
Copy link
Contributor Author

louiscb commented Apr 4, 2025

oh yea ofc!

@sneako sneako merged commit 2fcc8be into main Apr 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants