Merge pull request #142 from vbanos/fix-close-rename

Another exception when trying to close a WARC file
This commit is contained in:
Noah Levitt 2019-09-26 11:20:27 -07:00 committed by GitHub
commit 22d786f72e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -170,11 +170,14 @@ class WarcWriter:
except Exception as exc: except Exception as exc:
self.logger.error( self.logger.error(
'could not unlock file %s (%s)', self.path, exc) 'could not unlock file %s (%s)', self.path, exc)
self.f.close() try:
finalpath = os.path.sep.join( self.f.close()
[self.directory, self.finalname]) finalpath = os.path.sep.join(
os.rename(self.path, finalpath) [self.directory, self.finalname])
os.rename(self.path, finalpath)
except Exception as exc:
self.logger.error(
'could not close and rename file %s (%s)', self.path, exc)
self.path = None self.path = None
self.f = None self.f = None