浏览代码

HUE-5121 [home] Old query format with / cannot be imported

Jenny Kim 9 年之前
父节点
当前提交
997158a
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      desktop/core/src/desktop/api2.py

+ 6 - 0
desktop/core/src/desktop/api2.py

@@ -446,6 +446,12 @@ def import_documents(request):
       deps_minus_history = [dep for dep in doc['fields'].get('dependencies', []) if len(dep) >= 3 and not dep[2]]
       doc['fields']['dependencies'] = deps_minus_history
 
+      # Replace illegal characters
+      if '/' in doc['fields']['name']:
+        new_name = doc['fields']['name'].replace('/', '-')
+        LOG.warn("Found illegal slash in document named: %s, renaming to: %s." % (doc['fields']['name'], new_name))
+        doc['fields']['name'] = new_name
+
       # Set last modified date to now
       doc['fields']['last_modified'] = datetime.now().replace(microsecond=0).isoformat()
       docs.append(doc)