Skip to content

Commit

Permalink
riff: flush file after chunk manipulations
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Nov 15, 2019
1 parent 55abe41 commit 2e6ad62
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mutagen/_riff.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def delete(self):
delete_bytes(self._fileobj, self.size, self.offset)
if self.parent_chunk is not None:
self.parent_chunk._remove_subchunk(self)
self._fileobj.flush()

def _update_size(self, size_diff, changed_subchunk=None):
"""Update the size of the chunk"""
Expand Down Expand Up @@ -153,6 +154,7 @@ def resize(self, new_data_size):
new_data_size + padding, self.data_offset)
size_diff = new_data_size - self.data_size
self._update_size(size_diff)
self._fileobj.flush()

def padding(self):
"""Returns the number of padding bytes (0 or 1).
Expand Down Expand Up @@ -231,6 +233,7 @@ def insert_chunk(self, id_, data=None):
if data:
chunk.write(data)
self.subchunks().append(chunk)
self._fileobj.flush()
return chunk

def _remove_subchunk(self, chunk):
Expand Down

0 comments on commit 2e6ad62

Please sign in to comment.