fix when no read right on file
This commit is contained in:
parent
bd532e5c22
commit
b1611621dc
14
interface.py
14
interface.py
@ -11,6 +11,7 @@ from werkzeug.utils import secure_filename
|
||||
import errno
|
||||
import media
|
||||
|
||||
|
||||
class ReverseProxied(object):
|
||||
'''Wrap the application in this middleware and configure the
|
||||
front-end server to add these headers, to let you quietly bind
|
||||
@ -72,7 +73,7 @@ def index():
|
||||
item = ('file', request.form['add_file'], datetime.now().timestamp())
|
||||
var.playlist.append(item)
|
||||
|
||||
elif ('add_folder' in request.form and ".." not in request.form['add_folder']) or ('add_folder_recursively' in request.form and ".." not in request.form['add_folder_recursively']) :
|
||||
elif ('add_folder' in request.form and ".." not in request.form['add_folder']) or ('add_folder_recursively' in request.form and ".." not in request.form['add_folder_recursively']):
|
||||
try:
|
||||
folder = request.form['add_folder']
|
||||
except:
|
||||
@ -90,7 +91,7 @@ def index():
|
||||
print('Adding to playlist: ', files)
|
||||
var.playlist.extend(files)
|
||||
|
||||
elif 'add_url' in request.form :
|
||||
elif 'add_url' in request.form:
|
||||
var.playlist.append(['url', request.form['add_url']])
|
||||
|
||||
elif 'add_radio' in request.form:
|
||||
@ -162,10 +163,10 @@ def upload():
|
||||
elif '../' in targetdir:
|
||||
return redirect("./", code=406)
|
||||
|
||||
#print('Uploading file:')
|
||||
#print('filename:', filename)
|
||||
#print('targetdir:', targetdir)
|
||||
#print('mimetype:', file.mimetype)
|
||||
# print('Uploading file:')
|
||||
# print('filename:', filename)
|
||||
# print('targetdir:', targetdir)
|
||||
# print('mimetype:', file.mimetype)
|
||||
|
||||
if "audio" in file.mimetype:
|
||||
storagepath = os.path.abspath(os.path.join(var.music_folder, targetdir))
|
||||
@ -187,6 +188,7 @@ def upload():
|
||||
else:
|
||||
return redirect("./", code=409)
|
||||
|
||||
|
||||
@web.route('/download', methods=["GET"])
|
||||
def download():
|
||||
if 'file' in request.args:
|
||||
|
7
util.py
7
util.py
@ -21,7 +21,6 @@ def get_recursive_filelist_sorted(path):
|
||||
|
||||
fullpath = os.path.join(path, relroot, file)
|
||||
if not os.access(fullpath, os.R_OK):
|
||||
print("coucou")
|
||||
continue
|
||||
|
||||
mime = magic.from_file(fullpath, mime=True)
|
||||
@ -54,8 +53,12 @@ def zipdir(zippath, zipname_prefix=None):
|
||||
zipf = zipfile.ZipFile(zipname, 'w', zipfile.ZIP_DEFLATED)
|
||||
|
||||
for file in files:
|
||||
filepath = os.path.dirname(file)
|
||||
file_to_add = os.path.join(zippath, file)
|
||||
if not os.access(file_to_add, os.R_OK):
|
||||
continue
|
||||
if file in var.config.get('bot', 'ignored_files'):
|
||||
continue
|
||||
|
||||
add_file_as = os.path.relpath(os.path.join(zippath, file), os.path.join(zippath, '..'))
|
||||
zipf.write(file_to_add, add_file_as)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user