post opens new request for each file
This commit is contained in:
parent
c06ebc29dc
commit
94fa825e67
|
@ -251,22 +251,34 @@ def post_pack():
|
|||
res.raise_for_status()
|
||||
mods_remote = res.json()
|
||||
mods = [mod for mod in mods if mod.filename not in mods_remote]
|
||||
files = {}
|
||||
for mod in mods:
|
||||
files[mod.filename] = open(os.path.join('mods', mod.filename), 'rb')
|
||||
files[config_master.modpack_name + '.html'] = open(
|
||||
config_master.modpack_name +'.html', 'rb')
|
||||
|
||||
for mod in mods:
|
||||
files = {}
|
||||
files[mod.filename] = open(os.path.join('mods', mod.filename), 'rb')
|
||||
res = requests.post(
|
||||
url=config_master.remote_addr + '/post',
|
||||
data=data,
|
||||
files=files
|
||||
)
|
||||
res.raise_for_status()
|
||||
files[mod.filename].close()
|
||||
print(f"{mod.filename} uploaded.")
|
||||
|
||||
|
||||
files = {}
|
||||
files['modpack.db'] = open('modpack.db', 'rb')
|
||||
files[config_master.modpack_name + '.html'] = open(
|
||||
config_master.modpack_name +'.html', 'rb')
|
||||
res = requests.post(
|
||||
url=config_master.remote_addr + '/post',
|
||||
data=data,
|
||||
files=files
|
||||
)
|
||||
res.raise_for_status()
|
||||
for file in files.values():
|
||||
file.close()
|
||||
|
||||
print("modpack.db uploaded.")
|
||||
print(f"{config_master.modpack_name}.html uploaded.")
|
||||
print('Success!')
|
||||
|
||||
|
||||
|
|
|
@ -64,17 +64,20 @@ def post():
|
|||
if not argon2.verify(password, config_server.pw_hash):
|
||||
abort(401)
|
||||
|
||||
files = request.files.to_dict()
|
||||
if 'modpack.db' in files:
|
||||
db = request.files.get('database')
|
||||
app.config.get('db_lock').acquire()
|
||||
db.save('modpack.db')
|
||||
app.config.get('db_lock').release()
|
||||
files.pop('modpack.db')
|
||||
|
||||
if config_server.modpack_name + '.html' in files:
|
||||
summary = request.files.get(config_server.modpack_name + '.html')
|
||||
summary.save(config_server.modpack_name + '.html')
|
||||
files.pop(config_server.modpack_name + '.html')
|
||||
|
||||
for fname, file in request.files.items():
|
||||
if not fname.endswith('.jar'):
|
||||
continue
|
||||
for fname, file in files.items():
|
||||
file.save(os.path.join(config_server.mods_dir, fname))
|
||||
|
||||
def generate_hash(password):
|
||||
|
|
Loading…
Reference in New Issue
Block a user