修复偏移问题,修复代理问题
This commit is contained in:
@@ -250,7 +250,12 @@ def download_gcode(file_id):
|
||||
return redirect(url_for('main.files'))
|
||||
|
||||
gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode'
|
||||
filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
|
||||
conf = SystemConfig.query.filter_by(key='gcode_upload_folder').first()
|
||||
gcode_dir = conf.value if (conf and conf.value and os.path.exists(conf.value)) else current_app.config['UPLOAD_FOLDER']
|
||||
filepath = os.path.join(gcode_dir, gcode_filename)
|
||||
if not os.path.exists(filepath):
|
||||
fallback = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
|
||||
if os.path.exists(fallback): filepath = fallback
|
||||
|
||||
if os.path.exists(filepath):
|
||||
safe_name = print_file.original_filename.rsplit('.', 1)[0] + '.gcode'
|
||||
@@ -266,7 +271,12 @@ def preview_gcode(file_id):
|
||||
abort(403)
|
||||
|
||||
gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode'
|
||||
filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
|
||||
conf = SystemConfig.query.filter_by(key='gcode_upload_folder').first()
|
||||
gcode_dir = conf.value if (conf and conf.value and os.path.exists(conf.value)) else current_app.config['UPLOAD_FOLDER']
|
||||
filepath = os.path.join(gcode_dir, gcode_filename)
|
||||
if not os.path.exists(filepath):
|
||||
fallback = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
|
||||
if os.path.exists(fallback): filepath = fallback
|
||||
|
||||
content = "File not found or not ready."
|
||||
line_count = 0
|
||||
@@ -293,7 +303,11 @@ def delete_file(file_id):
|
||||
|
||||
stl_path = os.path.join(current_app.config['UPLOAD_FOLDER'], print_file.filename)
|
||||
gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode'
|
||||
gcode_path = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
|
||||
conf = SystemConfig.query.filter_by(key='gcode_upload_folder').first()
|
||||
gcode_dir = conf.value if (conf and conf.value and os.path.exists(conf.value)) else current_app.config['UPLOAD_FOLDER']
|
||||
gcode_path = os.path.join(gcode_dir, gcode_filename)
|
||||
fallback_gcode = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
|
||||
|
||||
proxy_path = stl_path + '.proxy.stl'
|
||||
|
||||
if os.path.exists(stl_path):
|
||||
@@ -302,6 +316,8 @@ def delete_file(file_id):
|
||||
os.remove(proxy_path)
|
||||
if os.path.exists(gcode_path):
|
||||
os.remove(gcode_path)
|
||||
if os.path.exists(fallback_gcode):
|
||||
os.remove(fallback_gcode)
|
||||
|
||||
db.session.delete(print_file)
|
||||
db.session.commit()
|
||||
|
||||
Reference in New Issue
Block a user