Skip to content

Commit 30409bc

Browse files
committed
Fix copy output failing if destination is hidden
1 parent c0ff671 commit 30409bc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

plugins/builder/pdf_builder.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,12 @@ def copy_assets_to_output(self) -> None:
356356
or src_st.st_mtime > dst_st.st_mtime
357357
or src_st.st_size != dst_st.st_size
358358
):
359-
shutil.copy2(src_file, dst_file)
360359
if ext == ".synctex.gz":
360+
unhide_file(dst_file)
361+
shutil.copy2(src_file, dst_file)
361362
hide_file(dst_file)
363+
else:
364+
shutil.copy2(src_file, dst_file)
362365
logger.debug(f"Updated {dst_file}")
363366

364367

@@ -368,3 +371,13 @@ def hide_file(file_name):
368371
ret = ctypes.windll.kernel32.SetFileAttributesW(file_name, FILE_ATTRIBUTE_HIDDEN)
369372
if not ret: # There was an error.
370373
raise ctypes.WinError()
374+
375+
376+
def unhide_file(file_name):
377+
if os.name == "nt":
378+
FILE_ATTRIBUTE_HIDDEN = 0x02
379+
attr = ctypes.windll.kernel32.GetFileAttributesW(file_name)
380+
attr &= ~FILE_ATTRIBUTE_HIDDEN
381+
ret = ctypes.windll.kernel32.SetFileAttributesW(file_name, attr)
382+
if not ret: # There was an error.
383+
raise ctypes.WinError()

0 commit comments

Comments
 (0)