Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validators say osxmetadata.json is malformed JSON #57

Closed
porg opened this issue Jul 14, 2022 · 7 comments
Closed

Validators say osxmetadata.json is malformed JSON #57

porg opened this issue Jul 14, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@porg
Copy link

porg commented Jul 14, 2022

Foreword

  • osxmetadata correctly performs its --backup and --restore operations, so I do not mind too much.

How I noticed

  • But a the typical Mac user I quick look almost any file during work.
  • So when using osxmetadata and asking myself things like "Has osxmetadata picked up that file?" or "Has it picked up that particular metadata attribute?" I tend to just do a quick quicklook.
  • And here my QuickLook plugin for JSON tells me it's malformed.

Other checks

osxmetadata JSON malformed

Followup

  • If you decide too fix this indeed
  • Please make sure later versions can convert old malformed JSONs, and fix them when encountering them
  • Maybe also offer a batch script like find /Volumes/yourVolume/ -name ".osxmetadata.json" -exec "<do the fixing/corrections>"
@RhetTbull
Copy link
Owner

Thanks for the detailed report. The basic problem is that technically JSON expects an array of values (enclosed in square brackets) when there is more than one record but osxmetadata writes each file record as a separate JSON record per line without the syntax of a JSON array. Each record (line) is valid JSON but not the whole file. I could change this easily but detecting the old style vs the new style would be difficult. The format was designed to be very simple and works fine for osxmetadata. I'll have to think on this to decide if it's worth changing.

@RhetTbull RhetTbull added the bug Something isn't working label Jul 15, 2022
@RhetTbull
Copy link
Owner

I decided it was better to have well-formed JSON than to keep the existing format so v0.99.38 will silently upgrade any .osxmetadata.json file it accesses with --backup to be well-formed JSON. This breaks backwards compatibility so once you upgrade you cannot use an old version of osxmetadata to backup or restore.

@RhetTbull
Copy link
Owner

@all-contributors please add @porg for bug

@allcontributors
Copy link
Contributor

@RhetTbull

I've put up a pull request to add @porg! 🎉

@porg
Copy link
Author

porg commented Jul 25, 2022

👍 Thanks for the credits! 😉

@porg
Copy link
Author

porg commented Oct 25, 2022

Today via pipx I upgraded osxmetadata to v1.0.0 and it created a wellformed JSON which my QuickLookJSON shows just nicely.

@RhetTbull
Copy link
Owner

@porg Great! Glad it's working well now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants