Merge with bugfix-0.5
/mp3togo/track.py
blob:385ab9c3710428a7130b1abc9ebdb7e25f6bf3bf -> blob:1598d6776c0c5dba75274c891e8cb6138cd7e6da
--- mp3togo/track.py
+++ mp3togo/track.py
@@ -255,16 +255,42 @@ class Track:
tasks.append(job)
del job
- # Consider the track done if the output file exists:
- if os.path.exists(self._outname) and not opts['force']:
- opts.log(1, "Skipping existing file: %s\n" % self._outname)
- self._queue = tuple(tasks)
- if self._hash and self._cache:
- self._cache.release(self._hash)
- for tsk in self._queue:
- tsk._status = task.DONE
- self._state = DONE
- return
+ ## Consider the track done if the output file exists:
+ #if os.path.exists(self._outname) and not opts['force']:
+ # opts.log(1, "Skipping existing file: %s\n" % self._outname)
+ # self._queue = tuple(tasks)
+ # if self._hash and self._cache:
+ # self._cache.release(self._hash)
+ # for tsk in self._queue:
+ # tsk._status = task.DONE
+ # self._state = DONE
+ # return
+ if not opts['force']:
+ if os.path.exists(self._outname):
+ # In update mode, consider the track done if an existing file is older than the source
+ if opts['update']:
+ sourceinfo = os.stat(self._filename)
+ targetinfo = os.stat(self._outname)
+ if targetinfo.st_mtime >= sourceinfo.st_mtime:
+ opts.log(1, "Skipping up to date file: %s\n" % self._outname)
+ self._queue = tuple(tasks)
+ if self._hash and self._cache:
+ self._cache.release(self._hash)
+ for tsk in self._queue:
+ tsk._status = task.DONE
+ self._state = DONE
+ return
+ else:
+ opts.log(1, "Replacing out of date file: %s\n" % self._outname)
+ else: # Consider the track done if the output file exists:
+ opts.log(1, "Skipping existing file: %s\n" % self._outname)
+ self._queue = tuple(tasks)
+ if self._hash and self._cache:
+ self._cache.release(self._hash)
+ for tsk in self._queue:
+ tsk._status = task.DONE
+ self._state = DONE
+ return
# Ready to go
self._queue = tuple(tasks)
@@ -288,4 +314,3 @@ class Track:
child._parent = None
self._queue = ()
-