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
stream: don't try to read from all-sparse/no-data files #13817
Conversation
Download the artifacts for this pull request: |
Checks reveal support for There is one exception. The check fails in |
|
Cool. Thanks for the info. |
The use case is strange but I can't think of any downsides of rejecting empty files early like this, so should be fine. |
14a79f6
to
98a5bb8
Compare
Review addressed. |
``` dd if=/dev/zero of=/tmp/10g.empty bs=1 seek=10G count=0 dd if=/dev/zero of=/tmp/10m.empty bs=1 seek=10M count=0 time mpv /tmp/10{g,m}.empty ``` I keep files with the name format `${name}-${hash}.${ext}.empty` around, where the original is removed, and a sparse file with the size of the original is created instead. A lot of time is wasted on such files when going through playlists/directories that include some of them. This admittedly may not be that common of a use-case. Signed-off-by: Mohammad AlSaleh <[email protected]>
98a5bb8
to
4904175
Compare
@MoSal On MacOS Sonoma, this commit removes the ability to drag and drop a folder unto the mpv player. |
Interesting. The seek doesn't fail with directories in GNU/Linux, even if they are empty. Can you confirm this change fixes the issue? stream/stream_file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stream/stream_file.c b/stream/stream_file.c
index 0a6a697ff6..4b23d7fb83 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -359,7 +359,7 @@ static int open_f(stream_t *stream, const struct stream_open_args *args)
#endif
#if HAVE_SEEK_DATA
- if (stream->mode == STREAM_READ) {
+ if (stream->mode == STREAM_READ && !stream->is_directory) {
off_t first_data = lseek(p->fd, 0, SEEK_DATA);
if (first_data == (off_t)-1 && errno == ENXIO) {
MP_ERR(stream, "File is empty or all sparse (has no data).\n"); |
@kasper93 and I discussed on IRC that we will likely be reverting this anyway because it also introduces an error message if you pass an empty file to e.g. |
Yup @MoSal , that would skip the throwing of errors when it's a directory, dragging in a folder works fine now. PS: Perhaps this option to skip sparse files can also be added as one of the mpv list of 'features' in meson_options.txt so it can be disabled during compilation itself as well? |
@cheemeng |
I keep files with the name format
${name}-${hash}.${ext}.empty
around, where the original is removed, and a sparse file with the size of the original is created instead.A lot of time is wasted on such files when going through playlists/directories that include some of them.
This admittedly may not be that common of a use-case.