8000 Ensure IO is properly closed when importing NewPipe subscriptions by ChunkyProgrammer · Pull Request #4346 · iv-org/invidious · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Ensure IO is properly closed when importing NewPipe subscriptions #4346

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

Merged

Conversation

ChunkyProgrammer
Copy link
Contributor

File.open accepts a second argument which will close the initial stream (IO::Memory.new(body)) when the File stream closes.

I also made it so that the code is a bit more safe with closing connections. ex: if an error occurs. This may also fix some potential memory leaks

@ChunkyProgrammer ChunkyProgrammer requested a review from a team as a code owner December 20, 2023 05:25
@ChunkyProgrammer ChunkyProgrammer requested review from syeopite and removed request for a team December 20, 2023 05:25

user.watched += db.query_all("SELECT url FROM streams", as: String)
.map(&.lchop("https://www.youtube.com/watch?v="))
temp = File.tempfile(".db") do |tempfile|
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would we maybe want to randomly generate part of the file file's name? (ex: .db-{UUID}) I imagine this might cause some issues if invidious starts to use Concurrency

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that might be a huge problem! The ideal option would be ti use in-memory databases and use sqlite3_serialize, but that requires to make a PR to crystal-sqlite3

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, that would be even better! I imagine there might need to be a PR made here as well (if serialization is supported by other databases): crystal-db

Copy link
Member

Choose a reason for hiding this comment

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

In memory-databases are already supported in crystal-sqlite3 like so:

DB.open "sqlite3::memory" do | db |
  db.exec "create table contacts (name text, age integer)"
  db.exec "insert into contacts values (?, ?)", "John Doe", 30
end

The only thing that needs to be added is a way to actually access an in-memory database.

There's no need for a PR directly imo, an issue would be enough.

Copy link
Member

Choose a reason for hiding this comment

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

@SamantazFox SamantazFox added the need-testing This feature needs to be deployed and tested to see if it's working, and doesn't break something label Jan 7, 2024
@ChunkyProgrammer ChunkyProgrammer force-pushed the newpipe-import-close-on-error branch from 8c15384 to 67f98cb Compare April 30, 2024 23:34
@SamantazFox SamantazFox added the in-testing This feature has been deployed and is being tested label Jun 16, 2024
@ChunkyProgrammer ChunkyProgrammer force-pushed the newpipe-import-close-on-error branch from fcca23d to 67b362e Compare July 10, 2024 13:50
@SamantazFox SamantazFox removed the in-testing This feature has been deployed and is being tested label Jul 17, 2024
@ChunkyProgrammer ChunkyProgrammer force-pushed the newpipe-import-close-on-error branch from 67b362e to 702982a Compare August 13, 2024 19:12
@ChunkyProgrammer ChunkyProgrammer force-pushed the newpipe-import-close-on-error branch from 702982a to 77de46f Compare August 24, 2024 22:03
@ChunkyProgrammer ChunkyProgrammer force-pushed the newpipe-import-close-on-error branch from 77de46f to 2d1437f Compare October 1, 2024 02:03
@ChunkyProgrammer ChunkyProgrammer force-pushed the newpipe-import-close-on-error branch from 2d1437f to acfd07e Compare October 30, 2024 16:57
@SamantazFox SamantazFox added in-testing This feature has been deployed and is being tested and removed need-testing This feature needs to be deployed and tested to see if it's working, and doesn't break something labels Oct 30, 2024
@ChunkyProgrammer ChunkyProgrammer force-pushed the newpipe-import-close-on-error branch from acfd07e to bba1769 Compare November 17, 2024 18:13
@syeopite syeopite merged commit 4a31da4 into iv-org:master Jan 22, 2025
9 checks passed
@syeopite
Copy link
Member

Thank you for your work here! This should help make Invidious more stable on large instances 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-testing This feature has been deployed and is being tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0