add patch to fix file data
This commit is contained in:
parent
421a035375
commit
4ae03c1cb0
2 changed files with 32 additions and 0 deletions
|
|
@ -48,3 +48,4 @@ execute:frappe.db.sql("""update `tabSingles` set `value`=`doctype` where `field`
|
|||
frappe.patches.v4_1.enable_print_as_pdf #2014-06-17
|
||||
execute:frappe.db.sql("""update `tabDocPerm` set email=1 where parent='User' and permlevel=0 and `role`='All' and `read`=1 and apply_user_permissions=1""") #2014-07-15
|
||||
execute:frappe.db.sql("""update `tabPrint Format` set print_format_type='Client' where ifnull(print_format_type, '')=''""") #2014-07-28
|
||||
frappe.patches.v4_1.file_manager_fix
|
||||
|
|
|
|||
31
frappe/patches/v4_1/file_manager_fix.py
Normal file
31
frappe/patches/v4_1/file_manager_fix.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# MIT License. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import os
|
||||
from frappe.utils import get_files_path
|
||||
from frappe.utils.file_manager import get_content_hash, get_file
|
||||
|
||||
|
||||
def execute():
|
||||
for name, file_name, file_url in frappe.db.sql(
|
||||
"""select name, file_name, file_url from `tabFile Data`
|
||||
where file_name is not null and content_hash is null"""):
|
||||
b = frappe.get_doc('File Data', name)
|
||||
old_file_name = b.file_name
|
||||
b.file_name = os.path.basename(old_file_name)
|
||||
if old_file_name.startswith('files/') or old_file_name.startswith('/files/'):
|
||||
b.file_url = os.path.normpath('/' + old_file_name)
|
||||
else:
|
||||
b.file_url = os.path.normpath('/files/' + old_file_name)
|
||||
try:
|
||||
_file_name, content = get_file(name)
|
||||
b.content_hash = get_content_hash(content)
|
||||
except IOError:
|
||||
print 'Warning: Error processing ', name
|
||||
_file_name = old_file_name
|
||||
b.content_hash = None
|
||||
|
||||
b.save()
|
||||
Loading…
Add table
Reference in a new issue