Commit 04d390a6 by Őry Máté

store: use shutil.make_archive for archiving

fixes #69
parent 7a77678d
...@@ -100,23 +100,13 @@ def cmd_download(request, neptun, home_path): ...@@ -100,23 +100,13 @@ def cmd_download(request, neptun, home_path):
if not dl_path.startswith(home_path): if not dl_path.startswith(home_path):
abort(400, 'Invalid download path.') abort(400, 'Invalid download path.')
dl_hash = str(uuid.uuid4()) dl_hash = str(uuid.uuid4())
if( os.path.isfile(dl_path) ): dl_pub = os.path.join(ROOT_WWW_FOLDER, dl_hash)
os.symlink(dl_path, ROOT_WWW_FOLDER+'/'+dl_hash) if os.path.isfile(dl_path):
# Debug os.symlink(dl_path, dl_pub)
# redirect('http://store.cloud.ik.bme.hu:8080/dl/'+dl_hash)
return json.dumps({'LINK' : SITE_URL+'/dl/'+dl_hash}) return json.dumps({'LINK' : SITE_URL+'/dl/'+dl_hash})
else: else:
try: shutil.make_archive(dl_pub, 'zip', dl_path)
os.makedirs(TEMP_DIR+'/'+neptun, 0700) return json.dumps({'LINK' : SITE_URL+'/dl/'+dl_hash+'.zip'})
except:
pass
folder_name = os.path.basename(dl_path)
temp_path = TEMP_DIR+'/'+neptun+'/'+folder_name+'.zip'
with open(os.devnull, "w") as fnull:
# zip -rqDj vmi.zip /home/tarokkk/vpn-ik
result = subprocess.call(['/usr/bin/zip', '-rqDj', temp_path, dl_path], stdout = fnull, stderr = fnull)
os.symlink(temp_path, ROOT_WWW_FOLDER+'/'+dl_hash)
return json.dumps({'LINK' : SITE_URL+'/dl/'+dl_hash})
COMMANDS['DOWNLOAD'] = cmd_download COMMANDS['DOWNLOAD'] = cmd_download
# UPLOAD # UPLOAD
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment