Skip to content

Commit

Permalink
Explicitly clear hidden attribute for final files on MacOS
Browse files Browse the repository at this point in the history
Otherwise sometimes files will keep their hidden attribute after being
moved from a ".tmp" name to their final destination.
  • Loading branch information
I-Al-Istannen committed Nov 2, 2024
1 parent f5c4e82 commit 60d432b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions PFERD/output_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ 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
if hasattr(os, "chflags"):
import stat
flags = os.stat(info.local_path).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))
Expand Down

0 comments on commit 60d432b

Please sign in to comment.