mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-05-30 12:58:49 +00:00
llms :(
This commit is contained in:
@@ -5,6 +5,7 @@ import uuid
|
|||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
|
import zipfile
|
||||||
from main import get_symbol_address, patch_address, copy_file_to_src, zip_src_files
|
from main import get_symbol_address, patch_address, copy_file_to_src, zip_src_files
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -281,17 +282,30 @@ def patch():
|
|||||||
logger.error(f"Error patching file: {str(e)}")
|
logger.error(f"Error patching file: {str(e)}")
|
||||||
return jsonify({"error": f"Error patching file: {str(e)}"}), 500
|
return jsonify({"error": f"Error patching file: {str(e)}"}), 500
|
||||||
|
|
||||||
# Send the patched file directly
|
# Create a zip file containing the patched .so
|
||||||
|
try:
|
||||||
|
zip_filename = f"patched_{library_name}.zip"
|
||||||
|
zip_path = os.path.join('uploads', zip_filename)
|
||||||
|
with zipfile.ZipFile(zip_path, 'w') as zipf:
|
||||||
|
zipf.write(file_path, arcname=library_name)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error creating zip file: {str(e)}")
|
||||||
|
return jsonify({"error": f"Error creating zip file: {str(e)}"}), 500
|
||||||
|
|
||||||
|
# Send the zip file
|
||||||
try:
|
try:
|
||||||
return send_file(
|
return send_file(
|
||||||
file_path,
|
zip_path,
|
||||||
mimetype='application/octet-stream',
|
mimetype='application/zip',
|
||||||
as_attachment=True,
|
as_attachment=True,
|
||||||
download_name=f"patched_{library_name}"
|
download_name=zip_filename
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error sending patched file: {str(e)}")
|
logger.error(f"Error sending zip file: {str(e)}")
|
||||||
return jsonify({"error": f"Error sending patched file: {str(e)}"}), 500
|
return jsonify({"error": f"Error sending zip file: {str(e)}"}), 500
|
||||||
|
finally:
|
||||||
|
os.remove(file_path)
|
||||||
|
os.remove(zip_path)
|
||||||
|
|
||||||
@app.route('/api', methods=['POST'])
|
@app.route('/api', methods=['POST'])
|
||||||
def api():
|
def api():
|
||||||
|
|||||||
Reference in New Issue
Block a user