-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add attach_clean & change_theme * add attach_clean & change_theme * add * add readme --------- Co-authored-by: root <[email protected]>
- Loading branch information
1 parent
0dbb5d7
commit 71b8e52
Showing
13 changed files
with
200 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ yes = 是 | |
no = 否 | ||
read = 阅读 | ||
generate = 生成 | ||
clean = 清理 | ||
|
||
[init] | ||
default_proj_name = MinDoc演示项目 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import sqlite3 | ||
import os, glob | ||
|
||
conn = sqlite3.connect("mindoc.db") | ||
cur = conn.cursor() #通过建立数据库游标对象,准备读写操作 | ||
|
||
|
||
cmd = """ | ||
SELECT | ||
att.http_path | ||
FROM | ||
md_attachment AS att | ||
WHERE (att.document_id != 0 OR (NOT EXISTS( SELECT 1 FROM md_documents WHERE markdown LIKE ("%" || att.http_path || "%")))) | ||
AND (att.document_id = 0 OR (NOT EXISTS( SELECT 1 FROM md_documents WHERE att.document_id = document_id ))) | ||
""" | ||
cur.execute(cmd) | ||
file_list = cur.fetchall() | ||
for file_item in file_list: | ||
item_path = file_item[0] | ||
# 1. 删除os文件 | ||
if os.path.exists(os.path.join("..", item_path[1:])): | ||
os.remove(os.path.join("..", item_path[1:])) | ||
|
||
# 2. 查询os是否删除成功,成功则删除附件记录 | ||
if not os.path.exists(os.path.join("..", item_path[1:])): | ||
cmd = """ | ||
delete | ||
from md_attachment | ||
WHERE http_path = '{}' | ||
""".format(item_path) | ||
cur.execute(cmd) | ||
conn.commit() #保存提交,确保数据保存成功 | ||
|
||
conn.close() #关闭与数据库的连接 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters