Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
youtube-dl doesn't use locking to prevent concurrent writing to output files #10336
Comments
|
There is already a class A side note for developers, if someone is going to implement it: Jython does not have |
|
Found an old thread discussing similar scenarios. Closing this and leaving further discussion to #485 |
What is the purpose of your issue?
If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:
It doesn't matter which URLs it's being run on and I couldn't find any evidence of concurrency-aware operation in the
--helpoutput or FAQ, so I didn't think it was necessary to get verbose output from the actual operation.Description of your issue, suggested solution and other information
I run youtube-dl via a cronscript to download new videos on certain YouTube channels for offline viewing. However, I sometimes also run the script manually. This can result in two copies of
youtube-dltrying to download the same URL into the same folder at the same time.When that happens, the interactions between the two copies of youtube-dl cause the tail end of the video to be repeated in the file. youtube-dl should use some form of locking to prevent this.
Given the flaws in all of the more portable approaches to locking (eg. lock files can be stale, sockets aren't scoped to specific files, etc.), I'd suggest checking
os.nameand then using either POSIX-specific or Windows-specific locking functionality.For example, for POSIX OSes, this is one of the few situations where the flawed
fcntl-based locking system would work well.POSIX fcntl locks are advisory (they only affect future attempts to call
fcntl.lockf) and you're clearly not opening your files for exclusive access (good, because it allows me to play the*.partfiles as long as they download faster than they play), so this won't interfere with existing code in any way.