[hotfix] Avoid overwriting of file if it exists

This commit is contained in:
Pratik Vyas 2014-07-29 12:47:48 +05:30
parent 67e64f5707
commit cc0ac7e4c0

View file

@ -224,7 +224,7 @@ def get_content_hash(content):
def get_file_name(fname, optional_suffix):
n_records = frappe.db.sql("select name from `tabFile Data` where file_name='{}'".format(fname))
if len(n_records) > 0:
if len(n_records) > 0 or os.path.exists(get_files_path(fname)):
partial, extn = fname.rsplit('.', 1)
return '{partial}{suffix}.{extn}'.format(partial=partial, extn=extn, suffix=optional_suffix)
return fname