Skip to content

Conversation

@JSCU-CNI
Copy link
Contributor

As promised in #1387, this PR adds mimetype detection to the walkfs plugin.

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.54%. Comparing base (eef181a) to head (740d759).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1521      +/-   ##
==========================================
- Coverage   80.80%   80.54%   -0.26%     
==========================================
  Files         396      396              
  Lines       34826    34836      +10     
==========================================
- Hits        28141    28060      -81     
- Misses       6685     6776      +91     
Flag Coverage Δ
unittests 80.54% <100.00%> (-0.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 29, 2026

Merging this PR will degrade performance by 82.42%

❌ 1 regressed benchmark
✅ 10 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
test_benchmark_walkfs 58.9 ms 335.3 ms -82.42%

Comparing JSCU-CNI:walkfs-magic (740d759) with main (eef181a)

Open in CodSpeed

@Schamper
Copy link
Member

I'm surprised this doesn't alter the benchmark. Can you say anything if it has a noticeable performance impact?

@JSCU-CNI
Copy link
Contributor Author

JSCU-CNI commented Feb 3, 2026

I'm surprised this doesn't alter the benchmark.

The benchmark unfortunately only calls next() once. That means the benchmark only tests parsing the root filesystem entry.

Can you say anything if it has a noticeable performance impact?

Seems to be slightly slower in the test below on a ext4 filesystem with a default install of Ubuntu server (~100k files, ~4GB vmdk):

# amd64, cpython3.13

# without mimetype
$ time target-query -f walkfs ubuntu-server-24.04.2.vmx
...
real    13m3.404s
user    12m59.111s
sys     0m3.242s

# with mimetype
$ time target-query -f walkfs ubuntu-server-24.04.2.vmx
...
real    13m48.187s
user    13m30.432s
sys     0m5.915s

@B0TAxy
Copy link
Contributor

B0TAxy commented Feb 3, 2026

Maybe we can make the MIME type generation optional? That way, we can switch it on or off as needed.

@Schamper
Copy link
Member

Schamper commented Feb 3, 2026

The benchmark unfortunately only calls next() once.

Maybe change it to use itertools.islice with a sane number?

Maybe we can make the MIME type generation optional? That way, we can switch it on or off as needed.

I was thinking this too. Maybe use argparse.BooleanOptionalAction for a --mimetype/--no-mimetype flag.

is_suid (boolean): denotes if the entry has the set-user-id bit set.
attr (string[]): list of key-value pair attributes separated by '='.
fs_types (string[]): list of filesystem type(s) of the entry.
mimetype (string): detected mimetype of the entry.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this record docstring is still a bit useless at this point, but would you mind moving it up to the right spot?

@arg("--walkfs-path", default="/", help="path to recursively walk")
@arg("--capability", action="store_true", help="output capability records")
def walkfs(self, walkfs_path: str = "/", capability: bool = False) -> Iterator[FilesystemRecord]:
@arg("--no-mimetype", action="store_true", help="disable mimetype lookup of files")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaning towards flipping this and making it --mimetype to enable mimetype lookup. Sounds like a safer default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants