Skip to content

Commit

Permalink
Small bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Granroth-Wilding committed Apr 7, 2016
1 parent 66badfd commit a77579a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/python/pimlico/datatypes/tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ def add_document(self, archive_name, doc_name, data):
self.current_archive_name = archive_name
tar_filename = os.path.join(self.data_dir, "%s.tar" % archive_name)
# If we're appending a corpus and the archive already exists, append to it
self.current_archive_tar = tarfile.TarFile(tar_filename, mode="a" if self.append else "w")
try:
self.current_archive_tar = tarfile.TarFile(tar_filename, mode="a" if self.append else "w")
except tarfile.ReadError:
# Couldn't open the existing file to append to, write instead
self.current_archive_tar = tarfile.TarFile(tar_filename, mode="w")

# Keep a count of how many we've added so we can write metadata
self.doc_count += 1
Expand Down

0 comments on commit a77579a

Please sign in to comment.