Bugfix: Do not allow STL file upload if Cura support is not enabled

This commit is contained in:
Gina Häußge 2013-09-09 20:57:09 +02:00
parent d7e6d51cc2
commit 242e552f4d
3 changed files with 15 additions and 14 deletions

View file

@ -129,23 +129,24 @@ class GcodeManager:
if not file or not destination:
return None, True
local = True if destination == FileDestinations.LOCAL else False
curaEnabled = self._settings.getBoolean(["cura", "enabled"])
filename = file.filename
absolutePath = self.getAbsolutePath(file.filename, mustExist=False)
absolutePath = self.getAbsolutePath(filename, mustExist=False)
gcode = isGcodeFileName(filename)
if absolutePath is None:
if absolutePath is None or (not curaEnabled and not gcode):
return None, True
file.save(absolutePath)
filename = file.filename
if isGcodeFileName(filename):
if gcode:
return self.processGcode(absolutePath), True
curaEnabled = self._settings.get(["cura", "enabled"])
if curaEnabled and isSTLFileName(filename) and local:
self.processStl(absolutePath)
return filename, False
else:
local = (destination == FileDestinations.LOCAL)
if curaEnabled and isSTLFileName(filename) and local:
self.processStl(absolutePath)
return filename, False
def getFutureFileName(self, file):
@ -214,7 +215,7 @@ class GcodeManager:
if absolutePath is None:
return
os.remove(absolutePath)
if os.path.exists(stlPath):
os.remove(stlPath)
@ -455,7 +456,7 @@ class MetadataAnalyzer:
def _analyzeGcode(self, filename):
path = self._getPathCallback(filename)
if path is None:
if path is None or not os.path.exists(path):
return
self._currentFile = filename

View file

@ -406,7 +406,7 @@ def uploadGcodeFile():
currentSd = currentJob["sd"]
futureFilename = gcodeManager.getFutureFilename(file)
if futureFilename is None:
if futureFilename is None or (not settings().getBoolean(["cura", "enabled"]) and not util.isGcodeFileName(futureFilename)):
return make_response("Can not upload file %s, wrong format?" % file.filename, 400)
if futureFilename == currentFilename and sd == currentSd and printer.isPrinting() or printer.isPaused():

View file

@ -65,7 +65,7 @@ $(function() {
function gcode_upload_fail(e, data) {
$.pnotify({
title: "Upload failed",
text: "<p>Could not upload the file. Make sure it is a GCODE file and has one of the following extensions: .gcode, .gco</p><p>Server reported: <pre>" + data.jqXHR.responseText + "</pre></p>",
text: "<p>Could not upload the file. Make sure that it is a GCODE file and has the extension \".gcode\" or \".gco\" or that it is an STL file with the extension \".stl\" and Cura support is enabled and configured.</p><p>Server reported: <pre>" + data.jqXHR.responseText + "</pre></p>",
type: "error",
hide: false
});