mirror of
https://github.com/haiwen/seahub.git
synced 2025-10-22 03:16:34 +00:00
optimize code
This commit is contained in:
@@ -29,4 +29,3 @@ pypinyin==0.52.*
|
|||||||
dnspython==2.6.*
|
dnspython==2.6.*
|
||||||
pillow-heif==0.18.*
|
pillow-heif==0.18.*
|
||||||
redis==5.0.*
|
redis==5.0.*
|
||||||
html-to-markdown==1.3.*
|
|
||||||
|
@@ -245,8 +245,7 @@ def convert_file(path, username, doc_uuid, download_url, upload_url, src_type, d
|
|||||||
'src_type': src_type,
|
'src_type': src_type,
|
||||||
'dst_type': dst_type,
|
'dst_type': dst_type,
|
||||||
}
|
}
|
||||||
# url = FILE_CONVERTER_SERVER_URL.rstrip('/') + '/api/v1/file-convert/'
|
url = FILE_CONVERTER_SERVER_URL.rstrip('/') + '/api/v1/file-convert/'
|
||||||
url = 'http://127.0.0.1:8888/api/v1/file-convert/'
|
|
||||||
resp = requests.post(url, json=params, headers=headers, timeout=30)
|
resp = requests.post(url, json=params, headers=headers, timeout=30)
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
@@ -314,8 +313,7 @@ def confluence_to_wiki(filename, download_url, upload_url, username, seafile_ser
|
|||||||
'username': username,
|
'username': username,
|
||||||
'seafile_server_url': seafile_server_url
|
'seafile_server_url': seafile_server_url
|
||||||
}
|
}
|
||||||
# url = FILE_CONVERTER_SERVER_URL.rstrip('/') + '/api/v1/confluence-to-wiki/'
|
url = FILE_CONVERTER_SERVER_URL.rstrip('/') + '/api/v1/confluence-to-wiki/'
|
||||||
url = 'http://127.0.0.1:8888/api/v1/confluence-to-wiki/'
|
|
||||||
resp = requests.post(url, json=params, headers=headers, timeout=30)
|
resp = requests.post(url, json=params, headers=headers, timeout=30)
|
||||||
return resp.content
|
return resp.content
|
||||||
|
|
||||||
|
@@ -1714,11 +1714,16 @@ class ImportConfluenceView(APIView):
|
|||||||
sdoc_output_dir = self._download_sdoc_files(repo_id, space_key, username)
|
sdoc_output_dir = self._download_sdoc_files(repo_id, space_key, username)
|
||||||
sdoc_files = list(Path(sdoc_output_dir).glob('*.sdoc'))
|
sdoc_files = list(Path(sdoc_output_dir).glob('*.sdoc'))
|
||||||
self._process_zip_file(wiki, extract_dir, sdoc_files, cf_id_to_cf_title_map, username)
|
self._process_zip_file(wiki, extract_dir, sdoc_files, cf_id_to_cf_title_map, username)
|
||||||
# shutil.rmtree(extract_dir)
|
# delete server tmp dir
|
||||||
|
seafile_api.del_file(repo_id, '/',
|
||||||
|
json.dumps(['tmp']), username)
|
||||||
|
# clean repo trash
|
||||||
|
seafile_api.clean_up_repo_history(repo_id, 0)
|
||||||
|
shutil.rmtree(extract_dir)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
# if os.path.exists(extract_dir):
|
if os.path.exists(extract_dir):
|
||||||
# shutil.rmtree(extract_dir)
|
shutil.rmtree(extract_dir)
|
||||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error')
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error')
|
||||||
|
|
||||||
repo = seafile_api.get_repo(repo_id)
|
repo = seafile_api.get_repo(repo_id)
|
||||||
@@ -1899,9 +1904,7 @@ class ImportConfluenceView(APIView):
|
|||||||
exist_dir.append(target_dir)
|
exist_dir.append(target_dir)
|
||||||
self._upload_attachment_file(wiki_id, target_dir, file_path, username)
|
self._upload_attachment_file(wiki_id, target_dir, file_path, username)
|
||||||
|
|
||||||
def _upload_cf_images(self, wiki_id, directory, username, exist_dir):
|
def _upload_cf_images(self, wiki_id, image_dir, username, exist_dir):
|
||||||
image_dir = os.path.join(directory, 'images/')
|
|
||||||
image_dir = os.path.normpath(image_dir)
|
|
||||||
wiki_images_dir = 'images/'
|
wiki_images_dir = 'images/'
|
||||||
if os.path.exists(image_dir):
|
if os.path.exists(image_dir):
|
||||||
for root, _, files in os.walk(image_dir):
|
for root, _, files in os.walk(image_dir):
|
||||||
|
Reference in New Issue
Block a user