@@ -30,17 +30,19 @@ def __init__(self):
30
30
self .db_path = os .path .join (
31
31
appdata , "Cursor" , "User" , "globalStorage" , "storage.json"
32
32
)
33
- elif sys .platform == "darwin" : # macOS
34
- self .db_path = os .path .abspath (os .path .expanduser (
35
- "~/Library/Application Support/Cursor/User/globalStorage/storage.json"
36
- ))
37
- elif sys .platform == "linux" : # Linux 和其他类Unix系统
38
- self .db_path = os .path .abspath (os .path .expanduser (
39
- "~/.config/Cursor/User/globalStorage/storage.json"
40
- ))
33
+ elif sys .platform == "darwin" : # macOS
34
+ self .db_path = os .path .abspath (
35
+ os .path .expanduser (
36
+ "~/Library/Application Support/Cursor/User/globalStorage/storage.json"
37
+ )
38
+ )
39
+ elif sys .platform == "linux" : # Linux 和其他类Unix系统
40
+ self .db_path = os .path .abspath (
41
+ os .path .expanduser ("~/.config/Cursor/User/globalStorage/storage.json" )
42
+ )
41
43
else :
42
44
raise NotImplementedError (f"不支持的操作系统: { sys .platform } " )
43
-
45
+
44
46
def generate_new_ids (self ):
45
47
"""生成新的机器ID"""
46
48
# 生成新的UUID
@@ -79,25 +81,16 @@ def reset_machine_ids(self):
79
81
print (
80
82
f"{ Fore .RED } { EMOJI ['ERROR' ]} 无法读写配置文件,请检查文件权限!{ Style .RESET_ALL } "
81
83
)
84
+ print (
85
+ f"{ Fore .RED } { EMOJI ['ERROR' ]} 如果你使用过 go-cursor-help 来修改 ID; 请修改文件只读权限 { self .db_path } { Style .RESET_ALL } "
86
+ )
82
87
return False
83
88
84
89
# 读取现有配置
85
90
print (f"{ Fore .CYAN } { EMOJI ['FILE' ]} 读取当前配置...{ Style .RESET_ALL } " )
86
91
with open (self .db_path , "r" , encoding = "utf-8" ) as f :
87
92
config = json .load (f )
88
93
89
- # 只在没有备份文件时创建备份
90
- backup_path = self .db_path + ".bak"
91
- if not os .path .exists (backup_path ):
92
- print (
93
- f"{ Fore .YELLOW } { EMOJI ['BACKUP' ]} 创建配置备份: { backup_path } { Style .RESET_ALL } "
94
- )
95
- shutil .copy2 (self .db_path , backup_path )
96
- else :
97
- print (
98
- f"{ Fore .YELLOW } { EMOJI ['INFO' ]} 已存在备份文件,跳过备份步骤{ Style .RESET_ALL } "
99
- )
100
-
101
94
# 生成新的ID
102
95
print (f"{ Fore .CYAN } { EMOJI ['RESET' ]} 生成新的机器标识...{ Style .RESET_ALL } " )
103
96
new_ids = self .generate_new_ids ()
@@ -125,6 +118,7 @@ def reset_machine_ids(self):
125
118
return False
126
119
except Exception as e :
127
120
print (f"{ Fore .RED } { EMOJI ['ERROR' ]} 重置过程出错: { str (e )} { Style .RESET_ALL } " )
121
+
128
122
return False
129
123
130
124
0 commit comments