Merge branch 'maintenance' into devel
Conflicts: src/octoprint/filemanager/__init__.py
This commit is contained in:
commit
f43381ce30
5 changed files with 56 additions and 11 deletions
|
|
@ -212,9 +212,9 @@ class FileManager(object):
|
|||
file_name = storage_manager.split_path(path)
|
||||
|
||||
# we'll use the default printer profile for the backlog since we don't know better
|
||||
queue_entry = QueueEntry(file_name, entry, file_type, storage_type, path, self._printer_profile_manager.get_default())
|
||||
self._analysis_queue.enqueue(queue_entry, high_priority=False)
|
||||
counter += 1
|
||||
queue_entry = QueueEntry(file_name, file_type, storage_type, path, self._printer_profile_manager.get_default())
|
||||
if self._analysis_queue.enqueue(queue_entry, high_priority=False):
|
||||
counter += 1
|
||||
self._logger.info("Added {counter} items from storage type \"{storage_type}\" to analysis queue".format(**locals()))
|
||||
|
||||
def add_storage(self, storage_type, storage_manager):
|
||||
|
|
|
|||
|
|
@ -72,9 +72,10 @@ class AnalysisQueue(object):
|
|||
|
||||
def enqueue(self, entry, high_priority=False):
|
||||
if not entry.type in self._queues:
|
||||
return
|
||||
return False
|
||||
|
||||
self._queues[entry.type].enqueue(entry, high_priority=high_priority)
|
||||
return True
|
||||
|
||||
def pause(self):
|
||||
for queue in self._queues.values():
|
||||
|
|
|
|||
|
|
@ -312,6 +312,18 @@ class LessSimpleCache(BaseCache):
|
|||
return False
|
||||
return len(self._cache) > self._threshold
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.get(key)
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
return self.set(key, value)
|
||||
|
||||
def __delitem__(self, key):
|
||||
return self.delete(key)
|
||||
|
||||
def __contains__(self, key):
|
||||
return key in self._cache
|
||||
|
||||
_cache = LessSimpleCache()
|
||||
|
||||
def cached(timeout=5 * 60, key=lambda: "view:%s" % flask.request.path, unless=None, refreshif=None, unless_response=None):
|
||||
|
|
@ -358,6 +370,9 @@ def cached(timeout=5 * 60, key=lambda: "view:%s" % flask.request.path, unless=No
|
|||
|
||||
return decorator
|
||||
|
||||
def is_in_cache(key=lambda: "view:%s" % flask.request.path):
|
||||
return key() in _cache
|
||||
|
||||
def cache_check_headers():
|
||||
return "no-cache" in flask.request.cache_control or "no-cache" in flask.request.pragma
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import os
|
|||
import datetime
|
||||
|
||||
from collections import defaultdict
|
||||
from flask import request, g, url_for, make_response, render_template, send_from_directory, redirect
|
||||
from flask import request, g, url_for, make_response, render_template, send_from_directory, redirect, abort
|
||||
|
||||
import octoprint.plugin
|
||||
|
||||
|
|
@ -20,6 +20,7 @@ from octoprint.settings import settings
|
|||
from octoprint.filemanager import get_all_extensions
|
||||
|
||||
import re
|
||||
import base64
|
||||
|
||||
from . import util
|
||||
|
||||
|
|
@ -33,6 +34,17 @@ _plugin_vars = None
|
|||
_valid_id_re = re.compile("[a-z_]+")
|
||||
_valid_div_re = re.compile("[a-zA-Z_-]+")
|
||||
|
||||
@app.route("/cached.gif")
|
||||
def in_cache():
|
||||
url = request.base_url.replace("/cached.gif", "/")
|
||||
key = lambda: "view:{}:{}".format(url, g.locale.language if g.locale else "en")
|
||||
if not util.flask.is_in_cache(key):
|
||||
return abort(404)
|
||||
|
||||
response = make_response(bytes(base64.b64decode("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")))
|
||||
response.headers["Content-Type"] = "image/gif"
|
||||
return response
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
global _templates, _plugin_names, _plugin_vars
|
||||
|
|
|
|||
|
|
@ -158,20 +158,20 @@
|
|||
if (baseUrl[baseUrl.length - 1] != "/") {
|
||||
baseUrl += "/";
|
||||
}
|
||||
var indexCachedUrl = baseUrl + "cached.gif";
|
||||
var serverOnlineUrl = baseUrl + "online.gif";
|
||||
var backendOnlineUrl = baseUrl + "intermediary.gif";
|
||||
|
||||
var serverTimeout;
|
||||
var cachedTimeout;
|
||||
|
||||
var message = window.document.getElementById("message");
|
||||
|
||||
var serverIsOnline = false;
|
||||
var serverOnlineCallback = function(result) {
|
||||
var indexCachedCallback = function(result) {
|
||||
if (result == "load") {
|
||||
// our online.gif loaded, so the server is up, let's reload
|
||||
serverIsOnline = true;
|
||||
// our cached.gif loaded, so the index is cached now, let's reload
|
||||
message.className = "pulsate1 green";
|
||||
message.innerText = "OctoPrint server online, reloading page...";
|
||||
message.innerText = "OctoPrint server ready, reloading page...";
|
||||
|
||||
var reloadUrl = baseUrl + currentQuery + currentFragment;
|
||||
if (reloadUrl == window.location.href) {
|
||||
|
|
@ -180,7 +180,21 @@
|
|||
window.location.href = reloadUrl;
|
||||
}
|
||||
} else {
|
||||
// online.gif still not available, let's look at
|
||||
// cached.gif still not available, let's look at it again in a second
|
||||
cachedTimeout = setTimeout(function() {
|
||||
ping(indexCachedUrl, timeout, indexCachedCallback);
|
||||
}, 1000)
|
||||
}
|
||||
};
|
||||
|
||||
var serverIsOnline = false;
|
||||
var serverOnlineCallback = function(result) {
|
||||
if (result == "load") {
|
||||
// our online.gif loaded, so the server is up, let's wait for it to become ready
|
||||
serverIsOnline = true;
|
||||
ping(indexCachedUrl, timeout, indexCachedCallback);
|
||||
} else {
|
||||
// online.gif still not available, let's look at it again later
|
||||
var interval = 10;
|
||||
if (intervals.length) {
|
||||
interval = intervals.shift();
|
||||
|
|
@ -209,6 +223,9 @@
|
|||
if (serverTimeout) {
|
||||
window.clearTimeout(serverTimeout);
|
||||
}
|
||||
if (cachedTimeout) {
|
||||
window.clearTimeout(cachedTimeout);
|
||||
}
|
||||
|
||||
message.className = "red";
|
||||
message.innerHTML = "Looks like something went wrong during startup, the server is gone again. You should check <code>octoprint.log</code>.";
|
||||
|
|
|
|||
Loading…
Reference in a new issue