Skip to content

Commit 4d99851

Browse files
authored
Merge pull request #7 from LolipopJ/master
chore: 提升工具使用稳定性
2 parents 5717972 + 1342839 commit 4d99851

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

main.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,23 @@ def openfile(self):
5454

5555

5656
def double_click_search_table(self, info):
57-
file_path = self.resultTable.item(info.row(), 0).text()
58-
os.startfile(os.path.normpath(file_path))
57+
file_path = os.path.normpath(self.resultTable.item(info.row(), 0).text())
58+
if os.path.exists(file_path):
59+
os.startfile(file_path)
60+
else:
61+
QtWidgets.QMessageBox.warning(self, '警告', '图片文件不存在:' + file_path)
5962

6063

6164
def double_click_duplicate_table(self, info):
6265
col = info.column()
6366
if col > 1:
6467
return
6568
row = info.row()
66-
os.startfile(self.resultTableDuplicate.item(row, col).text())
69+
file_path = self.resultTableDuplicate.item(row, col).text()
70+
if os.path.exists(file_path):
71+
os.startfile(file_path)
72+
else:
73+
QtWidgets.QMessageBox.warning(self, '警告', '图片文件不存在:' + file_path)
6774

6875

6976
def start_search(self):

utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ def remove_nonexists(self):
9999
exists_index = json.loads(open(self.exists_index_path, 'rb').read())
100100
for idx in tqdm(range(len(exists_index)), ascii=True, desc='删除不存在文件'):
101101
if not os.path.exists(exists_index[idx]):
102-
exists_index[idx] = NOTEXISTS
103-
self.ir_engine.hnsw_index.mark_deleted(idx)
102+
exists_index[idx] = NOTEXISTS
103+
try:
104+
self.ir_engine.hnsw_index.mark_deleted(idx)
105+
except:
106+
pass
104107
with open(self.exists_index_path, 'wb') as wp:
105108
wp.write(json.dumps(exists_index,ensure_ascii=False).encode('UTF-8'))
106109

0 commit comments

Comments
 (0)