Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve thumbnails over P2P #2524

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

oscartbeaumont
Copy link
Contributor

@oscartbeaumont oscartbeaumont commented May 30, 2024

This PR builds on top of #2523 to allow thumbnails to be served via P2P from the node where the file exists.

Although we will sync preview media, having the ability to serve it over P2P means we can suffice before the first sync and we can also support scenarios were only a portion of the preview media is sunk.

Copy link

vercel bot commented May 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
relay_test ❌ Failed (Inspect) May 30, 2024 2:15pm
spacedrive-landing ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 2:15pm
spacedrive-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 2:15pm

let (path, home_node) = if library_id == "ephemeral" {
(get_ephemeral_thumb_key(&cas_id), None)
} else {
let library_id = Uuid::from_str(&library_id).map_err(bad_request)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By running these database queries within the file serving code, this PR significantly slows the loading of all preview media so we might want to do this out of band.

loadState.thumbnail !== 'error' &&
itemData.hasLocalThumbnail &&
itemData.thumbnailKey.length > 0
loadState.thumbnail !== 'error' // &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this check disabled the node will just fallback to the placeholder instead of making a request over P2P to the other node for the file.

Obviously disabling it like i've done here is not a permanent solution.

if (itemData.thumbnailKey.length > 0)
return platform.getThumbnailUrlByThumbKey(itemData.thumbnailKey);
if (itemData.casId)
return platform.getThumbnailUrlByThumbKey(library.uuid, itemData.casId);
Copy link
Contributor Author

@oscartbeaumont oscartbeaumont May 30, 2024

Choose a reason for hiding this comment

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

With the current implementation this can be called as:

  • platform.getThumbnailUrlByThumbKey("ephemeral", itemData.casId)
  • platform.getThumbnailUrlByThumbKey(library.uuid, itemData.casId)

As the codebase has no calls using the "ephemeral" variant I am certain this PR breaks thumbnails for the ephemeral explorer.

Copy link
Contributor Author

@oscartbeaumont oscartbeaumont left a comment

Choose a reason for hiding this comment

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

As I finish at Spacedrive tomorrow i'm not going to be able to drive this PR to completion but i've solved the P2P part making it easy for someone else to pick up if they can fix the thumbnail handling parts.

@jamiepine
Copy link
Member

lets get this picked up @ameer2468

@matheus-consoli matheus-consoli self-assigned this Jun 18, 2024
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