diff --git a/CHANGELOG.md b/CHANGELOG.md index 3926f7a..2524b66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ ambiguous situations. - Crawling of nested courses - Downloading of links with no target URL - Handle row flex on description pages +- Files sometimes appearing as hidden on MacOS ## 3.6.0 - 2024-10-23 diff --git a/PFERD/output_dir.py b/PFERD/output_dir.py index 09cf133..e1a1a85 100644 --- a/PFERD/output_dir.py +++ b/PFERD/output_dir.py @@ -425,6 +425,17 @@ async def download( return FileSinkToken(self, remote_path, path, local_path, heuristics, on_conflict) def _update_metadata(self, info: DownloadInfo) -> None: + # Clear hidden attribute on MacOS + # chflags is only available on some unixes + if hasattr(os, "chflags"): + import stat + stat_result = os.stat(info.local_path) + # Not present on all unixes + if hasattr(stat_result, "st_flags"): + flags = getattr(stat_result, "st_flags") + flags &= ~stat.UF_HIDDEN + os.chflags(info.local_path, flags) + if mtime := info.heuristics.mtime: mtimestamp = mtime.timestamp() os.utime(info.local_path, times=(mtimestamp, mtimestamp))