Skip to content

Commit 84397e3

Browse files
committed
Merge branch 'main' into gui-new
2 parents 347c50a + 3112ed7 commit 84397e3

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

pbpy/pbconfig.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,18 @@ def get_user(section, key, default=None):
5555

5656
def shutdown():
5757
if not get("is_ci"):
58-
with open(get_user_config_filename(), 'w+') as user_config_file:
59-
user_config_file.truncate(0)
60-
user_config_file.seek(0)
58+
user_filename = get_user_config_filename()
59+
attributes = 0
60+
restore_hidden = False
61+
if os.name == "nt":
62+
import win32api, win32con
63+
attributes = win32api.GetFileAttributes(user_filename)
64+
restore_hidden = attributes & win32con.FILE_ATTRIBUTE_HIDDEN
65+
win32api.SetFileAttributes(user_filename, attributes & ~win32con.FILE_ATTRIBUTE_HIDDEN)
66+
with open(user_filename, 'w') as user_config_file:
6167
get_user_config().write(user_config_file)
68+
if restore_hidden:
69+
win32api.SetFileAttributes(user_filename, attributes)
6270

6371

6472
def generate_config(config_path, parser_func):

0 commit comments

Comments
 (0)