Plugin-Need to overwrite existing file and ignore always_overwrite.

This commit is contained in:
Jim Miller
2012-01-08 15:54:38 -06:00
parent 413c24d149
commit 35c4f0c609
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ def do_download_for_worker(book,options):
elif options['collision'] in (ADDNEW, SKIP, OVERWRITE, OVERWRITEALWAYS) or \
('epub_for_update' not in book and options['collision'] in (UPDATE, UPDATEALWAYS)):
print("write to %s"%outfile)
writer.writeStory(outfilename=outfile)
writer.writeStory(outfilename=outfile, forceOverwrite=True)
book['comment'] = 'Download %s completed, %s chapters.'%(options['fileform'],story.getMetadata("numChapters"))
## checks were done earlier, just update it.
+2 -2
View File
@@ -183,7 +183,7 @@ class BaseStoryWriter(Configurable):
self._write(out,END.substitute(self.story.metadata))
# if no outstream is given, write to file.
def writeStory(self,outstream=None,metaonly=False, outfilename=None):
def writeStory(self,outstream=None, metaonly=False, outfilename=None, forceOverwrite=False):
for tag in self.getConfigList("extratags"):
self.story.addToList("extratags",tag)
@@ -203,7 +203,7 @@ class BaseStoryWriter(Configurable):
os.mkdir(path) ## os.makedirs() doesn't work in 2.5.2?
## Check for output file date vs updated date here
if not self.getConfig('always_overwrite'):
if not (self.getConfig('always_overwrite') or forceOverwrite):
if os.path.exists(outfilename):
## date() truncs off time, which files have, but sites don't report.
lastupdated=self.story.getMetadataRaw('dateUpdated').date()