Skip to content

Spotlight: Fix timestamps and add additional attributes#2878

Merged
rdmark merged 1 commit intoNetatalk:mainfrom
NJRoadfan:fix-spotlight-metadata
Apr 11, 2026
Merged

Spotlight: Fix timestamps and add additional attributes#2878
rdmark merged 1 commit intoNetatalk:mainfrom
NJRoadfan:fix-spotlight-metadata

Conversation

@NJRoadfan
Copy link
Copy Markdown
Contributor

Upstream patch from Samba. Fixes: #2258

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 10, 2026

🤖 Augment PR Summary

Summary: Pulls in an upstream Samba fix for Spotlight metadata encoding to address incorrect timestamps (Fixes: #2258).

Changes:

  • Adds support for additional metadata keys: _kMDItemFileName, kMDItemLogicalSize, and kMDItemLastUsedDate.
  • Corrects the Spotlight epoch definition (2001-01-01 UTC) and updates date marshalling/unmarshalling to use an IEEE-754 double with microsecond precision.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread etc/afpd/spotlight_marshalling.c
Comment thread etc/afpd/spotlight.c Outdated
@NJRoadfan NJRoadfan force-pushed the fix-spotlight-metadata branch 3 times, most recently from c944de1 to f95a1f1 Compare April 10, 2026 23:37
Upstream patch from Samba. Fixes: Netatalk#2258

Update atime when client accesses file too.
@NJRoadfan NJRoadfan force-pushed the fix-spotlight-metadata branch from f95a1f1 to 01eb9e4 Compare April 11, 2026 03:42
@rdmark
Copy link
Copy Markdown
Member

rdmark commented Apr 11, 2026

great patch, I'm pleased to see the spotlight code getting some long-overdue love

I was thinking about attribution since this is ported from Samba; seems like portions were authored by Ralph in samba-team/samba@5d4ecea and samba-team/samba@5d4ecea

the convert_timespec_to_timeval structure was authored by Jeremy Allison in 2007 samba-team/samba@4952fe3 but maybe it can be considered boilerplate / trivial?

@NJRoadfan
Copy link
Copy Markdown
Contributor Author

Some (all?) platforms have a macro called TIMESPEC_TO_TIMEVAL in <sys/time.h>.

@rdmark rdmark merged commit df9f8bd into Netatalk:main Apr 11, 2026
53 checks passed
@NJRoadfan NJRoadfan deleted the fix-spotlight-metadata branch April 18, 2026 01:40
@rdmark
Copy link
Copy Markdown
Member

rdmark commented Apr 18, 2026

heads-up that this patch caused a breakage: when spotlight is active it's not possible to edit a file in-place on an AFP volume, e.g. with TextEdit on macOS

TextEdit warns that "another application has modified the file" and prevents you from saving, probably due to the timestamp changing in a way that it doesn't expect

@NJRoadfan
Copy link
Copy Markdown
Contributor Author

Steps to reproduce?

TextEdit (at least in Catalina) is not producing the same issue on my end with Spotlight enabled. I would be curious to see if this can be reproduced on a Samba share with Spotlight enabled as it uses the same method of updating the "Last Opened" time on the server side.

I am opening a text file, making changes, then saving in place. I do get a note from TextEdit the first time I save that the file system doesn't support storing revisions, but other then that it works fine.

@NJRoadfan
Copy link
Copy Markdown
Contributor Author

Give #2896 a try. I noticed a regression where mtime was being set to -1 on the filesystem. This is likely causing problems elsewhere.

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.

Support "Modified" and "Last opened" times

2 participants