Skip to content

Commit

Permalink
[scan] ensure metadata file copy is same size
Browse files Browse the repository at this point in the history
(re)writing metadata using ffmpeg may result in output files being a
smaller size IF the original metadata was null/zero padded - we
truncate the dst (in place copy) to match size
  • Loading branch information
whatdoineed2do/Ray committed Dec 31, 2023
1 parent 5ac283a commit 7fd0b97
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/library/filescanner_ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,12 @@ fast_copy(int fd_dst, int fd_src)
#else
// sendfile will work with non-socket output (i.e. regular file) on Linux 2.6.33+
struct stat fileinfo = { 0 };
int ret;
fstat(fd_src, &fileinfo);
return sendfile(fd_dst, fd_src, NULL, fileinfo.st_size);
ret = sendfile(fd_dst, fd_src, NULL, fileinfo.st_size);
if (ret < 0)
return -1;
return ftruncate(fd_dst, fileinfo.st_size);
#endif
}

Expand Down

0 comments on commit 7fd0b97

Please sign in to comment.