Call fflush() before ftruncate() to drop all buffered data (#914)

This avoids stale data presented to caller via a fread()

Current bug due to the buffered data can be seen in stripping mp3s of tags

    f.strip(ID3v1);
    f.strip(APE);

The ID3v1 tag sits at the end of file (strip calls ftruncate()) and the APE
strip performs a readFile() that would return the stream buffered/truncated data
and reinsert
This commit is contained in:
whatdoineed2do 2019-07-25 03:57:49 +01:00 committed by Stephen F. Booth
parent ba7adc2bc2
commit 79bc9ccf8e

View File

@ -493,6 +493,7 @@ void FileStream::truncate(long length)
#else
fflush(d->file);
const int error = ftruncate(fileno(d->file), length);
if(error != 0)
debug("FileStream::truncate() -- Coundn't truncate the file.");