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

Mutual exclusion for file writes #338

Merged
merged 6 commits into from
Sep 4, 2022
Merged

Mutual exclusion for file writes #338

merged 6 commits into from
Sep 4, 2022

Conversation

miraclx
Copy link
Owner

@miraclx miraclx commented Sep 4, 2022

Could be the case that a playlist, or an artist with two identical albums have identical tracks. Freyr, resolving them to the same source, ends up downloading the track to the same cache stage, encoding and writing it out to the same output file.

Lots of potential for clashes, and race conditions. At the end of the day, the file may end up corrupt.

It's a game of russian roulette, basically.

This patch makes it so, a file is only ever touched by freyr once in the entire lifetime of the program's execution.

So if a track is being downloaded by being on another album, that download task carries through for the whole program.

And if they're writing to the same file, well, only one gets to do the writing.

@github-actions
Copy link

github-actions bot commented Sep 4, 2022


🐋 🤖

A docker image for this PR has been built!

docker pull freyrcli/freyrjs-git:pr-338
Base Branch (master)
This Patch


What's this?

This docker image is a self-contained sandbox that includes all the patches made in this PR. Allowing others to easily use your patches without waiting for it to get merged and released officially.

For more context, see https://github.com/miraclx/freyr-js#docker-development.

@miraclx miraclx force-pushed the single_write_events branch from 439acd8 to da2fdc3 Compare September 4, 2022 02:15
@miraclx miraclx force-pushed the master branch 2 times, most recently from a64d984 to c113e07 Compare September 4, 2022 02:39
@miraclx miraclx merged commit b27657e into master Sep 4, 2022
@miraclx miraclx deleted the single_write_events branch September 4, 2022 02:44
miraclx added a commit that referenced this pull request Sep 4, 2022
@miraclx miraclx mentioned this pull request Dec 17, 2022
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.

1 participant