`isDirectory(at:)` discards prefetched resource values

Open Beginner friendly
#52 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
swift
Domain
desktop

Research direction

Start at the import loop that calls isDirectory(at:) after contentsOfDirectory(at:includingPropertiesForKeys:) prefetched .isDirectoryKey and .contentTypeKey. Compare it with url.contentType and read the resource value from each URL instead of making a fresh fileExists(atPath:isDirectory:) syscall. Done means the cached directory value is used for each URL while the import behavior remains unchanged.

Written by the indexing model from the issue text.

Description

Automatically found

contentsOfDirectory(at:includingPropertiesForKeys:) is called with [.contentTypeKey, .isDirectoryKey] — precisely so those values are cached on the returned URLs. But isDirectory(at:) calls fileExists(atPath:isDirectory:), a fresh syscall that ignores the cache, once per URL in the import loop.

Reading url.resourceValues(forKeys: [.isDirectoryKey]).isDirectory would use the prefetched value. (url.contentType already does the right thing.)

Dominant language
Swift
Stars
0
Forks
3
Avg merge
3d 2h
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from BlueHuskyStudios/DeadassSimpleMediaPlayer

All issues in BlueHuskyStudios/DeadassSimpleMediaPlayer

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.