Sort timelapses by mtime instead of ctime

Otherwise we get bad sorting after copying over the files from another
instance (e.g. after backup/restore as described on the wiki).
This commit is contained in:
Gina Häußge 2017-11-10 13:25:16 +01:00
parent 92b048c789
commit 0bb343e1d3
3 changed files with 18 additions and 18 deletions

View file

@ -93,7 +93,7 @@ $(function() {
if (a["name"].toLocaleLowerCase() > b["name"].toLocaleLowerCase()) return 1;
return 0;
},
"creation": function(a, b) {
"date": function(a, b) {
// sorts descending
if (a["date"] > b["date"]) return -1;
if (a["date"] < b["date"]) return 1;

View file

@ -106,7 +106,7 @@
<button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<li><a href="javascript:void(0)" data-bind="click: function() { listHelper.changeSorting('name'); }"><i class="fa fa-check" data-bind="style: {visibility: listHelper.currentSorting() == 'name' ? 'visible' : 'hidden'}"></i> {{ _('Sort by name') }} ({{ _('ascending') }})</a></li>
<li><a href="javascript:void(0)" data-bind="click: function() { listHelper.changeSorting('creation'); }"><i class="fa fa-check" data-bind="style: {visibility: listHelper.currentSorting() == 'creation' ? 'visible' : 'hidden'}"></i> {{ _('Sort by creation date') }} ({{ _('descending') }})</a></li>
<li><a href="javascript:void(0)" data-bind="click: function() { listHelper.changeSorting('date'); }"><i class="fa fa-check" data-bind="style: {visibility: listHelper.currentSorting() == 'date' ? 'visible' : 'hidden'}"></i> {{ _('Sort by date') }} ({{ _('descending') }})</a></li>
<li><a href="javascript:void(0)" data-bind="click: function() { listHelper.changeSorting('size'); }"><i class="fa fa-check" data-bind="style: {visibility: listHelper.currentSorting() == 'size' ? 'visible' : 'hidden'}"></i> {{ _('Sort by file size') }} ({{ _('descending') }})</a></li>
</ul>
</div>

View file

@ -92,7 +92,7 @@ def get_finished_timelapses():
"name": entry.name,
"size": util.get_formatted_size(entry.stat().st_size),
"bytes": entry.stat().st_size,
"date": util.get_formatted_datetime(datetime.datetime.fromtimestamp(entry.stat().st_ctime))
"date": util.get_formatted_datetime(datetime.datetime.fromtimestamp(entry.stat().st_mtime))
})
return files
@ -116,8 +116,8 @@ def get_unrendered_timelapses():
jobs[prefix]["count"] += 1
jobs[prefix]["bytes"] += entry.stat().st_size
if jobs[prefix]["timestamp"] is None or entry.stat().st_ctime < jobs[prefix]["timestamp"]:
jobs[prefix]["timestamp"] = entry.stat().st_ctime
if jobs[prefix]["timestamp"] is None or entry.stat().st_mtime < jobs[prefix]["timestamp"]:
jobs[prefix]["timestamp"] = entry.stat().st_mtime
with _job_lock:
global current_render_job
@ -140,7 +140,7 @@ def get_unrendered_timelapses():
def delete_unrendered_timelapse(name):
global _cleanup_lock
pattern = "{}*.jpg".format(util.glob_escape(name))
basedir = settings().getBaseFolder("timelapse_tmp")
@ -290,7 +290,7 @@ def configure_timelapse(config=None, persist=False):
ffmpeg_path = settings().get(["webcam", "ffmpeg"])
timelapse_precondition = snapshot_url is not None and snapshot_url.strip() != "" \
and ffmpeg_path is not None and ffmpeg_path.strip() != ""
type = config["type"]
if not timelapse_precondition and type is not None and type != "off":
logging.getLogger(__name__).warn("Essential timelapse settings unconfigured (snapshot URL or FFMPEG path) "
@ -298,7 +298,7 @@ def configure_timelapse(config=None, persist=False):
"in the config as well.")
type = "off"
config["type"] = "off"
if not persist:
# make sure we persist at least that timelapse is now disabled by default - we don't want the above
# warning to log
@ -312,31 +312,31 @@ def configure_timelapse(config=None, persist=False):
postRoll = 0
if "postRoll" in config and config["postRoll"] >= 0:
postRoll = config["postRoll"]
fps = 25
if "fps" in config and config["fps"] > 0:
fps = config["fps"]
if "zchange" == type:
retractionZHop = 0
if "options" in config and "retractionZHop" in config["options"] and config["options"]["retractionZHop"] >= 0:
retractionZHop = config["options"]["retractionZHop"]
minDelay = 5
if "options" in config and "minDelay" in config["options"] and config["options"]["minDelay"] > 0:
minDelay = config["options"]["minDelay"]
current = ZTimelapse(post_roll=postRoll, retraction_zhop=retractionZHop, min_delay=minDelay, fps=fps)
elif "timed" == type:
interval = 10
if "options" in config and "interval" in config["options"] and config["options"]["interval"] > 0:
interval = config["options"]["interval"]
capture_post_roll = True
if "options" in config and "capturePostRoll" in config["options"] and isinstance(config["options"]["capturePostRoll"], bool):
capture_post_roll = config["options"]["capturePostRoll"]
current = TimedTimelapse(post_roll=postRoll, interval=interval, fps=fps, capture_post_roll=capture_post_roll)
notify_callbacks(current)
@ -630,10 +630,10 @@ class Timelapse(object):
class ZTimelapse(Timelapse):
def __init__(self, retraction_zhop=0, min_delay=5.0, post_roll=0, fps=25):
Timelapse.__init__(self, post_roll=post_roll, fps=fps)
if min_delay < 0:
min_delay = 0
self._retraction_zhop = retraction_zhop
self._min_delay = min_delay
self._last_snapshot = None
@ -642,7 +642,7 @@ class ZTimelapse(Timelapse):
@property
def retraction_zhop(self):
return self._retraction_zhop
@property
def min_delay(self):
return self._min_delay