diff --git a/frappe/app.py b/frappe/app.py index 76018e391e..f8fed3b22a 100644 --- a/frappe/app.py +++ b/frappe/app.py @@ -143,11 +143,11 @@ def serve(port=8000, profile=False, site=None, sites_path='.'): if not os.environ.get('NO_STATICS'): application = SharedDataMiddleware(application, { - '/assets': os.path.join(sites_path, 'assets'), + b'/assets': os.path.join(sites_path, 'assets').encode("utf-8"), }) application = StaticDataMiddleware(application, { - '/files': os.path.abspath(sites_path) + b'/files': os.path.abspath(sites_path).encode("utf-8") }) run_simple('0.0.0.0', int(port), application, use_reloader=True, diff --git a/frappe/utils/file_manager.py b/frappe/utils/file_manager.py index 2e4f31e32f..e6a61789ed 100644 --- a/frappe/utils/file_manager.py +++ b/frappe/utils/file_manager.py @@ -6,7 +6,7 @@ import frappe import os, base64, re import hashlib import mimetypes -from frappe.utils import get_site_path, get_hook_method, get_files_path, random_string +from frappe.utils import get_site_path, get_hook_method, get_files_path, random_string, encode, cstr from frappe import _ from frappe import conf from copy import copy @@ -258,8 +258,11 @@ def get_content_hash(content): return hashlib.md5(content).hexdigest() def get_file_name(fname, optional_suffix): + # convert to unicode + fname = cstr(fname) + n_records = frappe.db.sql("select name from `tabFile Data` where file_name=%s", fname) - if len(n_records) > 0 or os.path.exists(get_files_path(fname).encode('utf-8')): + if len(n_records) > 0 or os.path.exists(encode(get_files_path(fname))): f = fname.rsplit('.', 1) if len(f) == 1: partial, extn = f[0], ""