From 15c9f4cceb0cbc1c908d0dca43e5dc0ab9bd17fc Mon Sep 17 00:00:00 2001 From: horsesword Date: Wed, 6 Oct 2021 23:03:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=9C=A8=E9=9D=9ENT?= =?UTF-8?q?FS=E7=A3=81=E7=9B=98=E4=B8=8A=E7=9A=84=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=80=A7bug=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 ++++++ tagdox.py | 44 +++++++++++++------ ...64\346\226\260\350\256\260\345\275\225.md" | 7 +++ 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index aaac7d4..3c8d1cc 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,22 @@ Tagdox / 标签文库,是用于对文档进行「标签化管理」的免费 ## 近期更新 +#### v0.21.1.2 2021年10月6日 + +修复了在非NTFS磁盘上的兼容性bug。 +文件夹区域也增加了鼠标指向效果。 +修改自建模块位置。 + +#### v0.21.1.1 2021年10月4日 + +储备:优化标签类封装逻辑,关闭文件前一直占用文件。 +储备:新增常用工具函数,直接对标签进行增加、删除、清空、查询。 +储备:新增依赖说明requirements.txt。 + #### v0.21.1.0 2021年10月4日 + 为文件列表的鼠标指向增加了高亮效果。 + #### v0.21.0.0 2021年10月3日 优化标签逻辑,采用NTFS流模式,不再影响文件名(测试版)。 优化右键响应,现在可以正确在被点击的项目处出现右键菜单了。 diff --git a/tagdox.py b/tagdox.py index aa31894..b66d633 100644 --- a/tagdox.py +++ b/tagdox.py @@ -47,11 +47,12 @@ URL_HELP = 'https://gitee.com/horse_sword/my-local-library' # 帮助的超链 URL_ADV = 'https://gitee.com/horse_sword/my-local-library/issues' # 提建议的位置 URL_CHK_UPDATE = 'https://gitee.com/horse_sword/my-local-library/releases' # 检查更新的位置 TAR = 'Tagdox / 标签文库' # 程序名称 -VER = 'v0.21.1.1' # 版本号 +VER = 'v0.21.1.2' # 版本号 """ ## 近期更新说明 -#### v0.21.1.1 2021年10月5日 +#### v0.21.1.2 2021年10月6日 +修复了在非NTFS磁盘上的兼容性bug。 文件夹区域也增加了鼠标指向效果。 修改自建模块位置。 #### v0.21.1.0 2021年10月4日 @@ -716,7 +717,10 @@ def get_file_part(tar): # try: with open(tar + ":tags", "r", encoding="utf8") as f: ftags += (set(list(map(lambda x: x.strip(), f.readlines())))) - except FileNotFoundError as e: + except FileNotFoundError: + pass + except Exception as e: + # print(e) pass mtime = os.stat(tar).st_mtime # 修改时间 @@ -726,6 +730,8 @@ def get_file_part(tar): # fsize = os.path.getsize(tar) # 文件大小,字节 fsize_k = fsize / (1024) # 换算到kB + if 0 < fsize_k < 0.1: + fsize_k = 0.1 fsize_k = round(fsize_k, 1) # 对文件目录的解析算法2: @@ -2844,6 +2850,7 @@ def exec_file_add_tag(filename, tag0, need_update=True): """ filename = filename.replace('\\', '/') tmp_final_name = filename + ntfs_error = False # # 增加NTFS流的标签解析 if TAG_METHOD == 'FILE_STREAM': @@ -2857,8 +2864,11 @@ def exec_file_add_tag(filename, tag0, need_update=True): # 增加标签 tags_old.append(tag0) tags_old.sort() - with open(filename + ":tags", "w", encoding="utf8") as f: - f.writelines(list(map(lambda x: x + "\n", tags_old))) + try: + with open(filename + ":tags", "w", encoding="utf8") as f: + f.writelines(list(map(lambda x: x + "\n", tags_old))) + except: + ntfs_error = True # # 更新缓存 update_one_of_dicT(filename) @@ -2871,7 +2881,8 @@ def exec_file_add_tag(filename, tag0, need_update=True): # str(tmp['full_path'])) # dicT[filename] = tmp_v # return tmp_final_name - else: + + if TAG_METHOD != 'FILE_STREAM' or ntfs_error: tag_list = tag0.split(V_SEP) tag_old = get_file_part(filename)['ftags'] # 已有标签 file_old = get_file_part(filename)['ffname'] # 原始的文件名 @@ -2881,7 +2892,7 @@ def exec_file_add_tag(filename, tag0, need_update=True): old_n = path_old + '/' + fname + fename new_n = old_n for i in tag_list: - if not i in tag_old: + if i not in tag_old: new_n = path_old + os.sep + fname + V_SEP + i + fename print(old_n) print(new_n) @@ -4369,7 +4380,7 @@ def exec_tree_file_drop_tag(event=None): try: with open(tmp_full_name + ":tags", "r", encoding="utf8") as f: tags_in_st = list(set(list(map(lambda x: x.strip(), f.readlines())))) - except FileNotFoundError as e: + except Exception as e: pass # if tag_value in tags_in_st: @@ -4377,10 +4388,13 @@ def exec_tree_file_drop_tag(event=None): tags_in_st.remove(tag_value) # 重写流 tags_in_st.sort() - with open(tmp_full_name + ":tags", "w", encoding="utf8") as f: - f.writelines(list(map(lambda x: x + "\n", tags_in_st))) - # 更新缓存 - update_one_of_dicT(tmp_full_name) + try: + with open(tmp_full_name + ":tags", "w", encoding="utf8") as f: + f.writelines(list(map(lambda x: x + "\n", tags_in_st))) + # 更新缓存 + update_one_of_dicT(tmp_full_name) + except: + pass # # 删除文件名里面的标签 res = get_file_part(tmp_full_name) @@ -4572,6 +4586,8 @@ def show_popup_menu_file(event): tmp_tags.append(i) except FileNotFoundError as e: pass + except: + pass try: for i in range(10000): # 删除已有标签 @@ -4630,6 +4646,8 @@ def show_popup_menu_file(event): tmp_tags.append(i) except FileNotFoundError as e: pass + except: + pass # if file_checked == 0: tmp_tags_from_files += tmp_tags @@ -4678,7 +4696,7 @@ def fixed_map_v2(tar, option): def exec_tree_folder_remove_mouse_highlight(event): - exec_tree_folder_mouse_highlight(event,clear_only=True) + exec_tree_folder_mouse_highlight(event, clear_only=True) def exec_tree_folder_mouse_highlight(event, clear_only=False): diff --git "a/\346\233\264\346\226\260\350\256\260\345\275\225.md" "b/\346\233\264\346\226\260\350\256\260\345\275\225.md" index a997a04..2cd0b38 100644 --- "a/\346\233\264\346\226\260\350\256\260\345\275\225.md" +++ "b/\346\233\264\346\226\260\350\256\260\345\275\225.md" @@ -10,10 +10,17 @@ ## 更新记录 +#### v0.21.1.2 2021年10月6日 +修复了在非NTFS磁盘上的兼容性bug。 +文件夹区域也增加了鼠标指向效果。 +修改自建模块位置。 + #### v0.21.1.1 2021年10月4日 + 储备:优化标签类封装逻辑,关闭文件前一直占用文件。 储备:新增常用工具函数,直接对标签进行增加、删除、清空、查询。 储备:新增依赖说明requirements.txt。 + #### v0.21.1.0 2021年10月4日 为文件列表的鼠标指向增加了高亮效果。 -- GitLab