DBRepair development

The test checks if your database file is readable by you from the terminal.
Then it prints the result to the screen, either it CanRead or it suggests you FixYourPerms.
It’s safe when copy-pasted. So whenever you’re bored or curious, let us know what you find.

@nibbles

Not understanding here.

  # Apple Mac
  elif [ -d "/Applications/Plex Media Server.app" ] && \
       [ -d "$HOME/Library/Application Support/Plex Media Server" ]; then

works if the invoking UID minimally has RX permission.

Given PMS runs as your username and then you run the script as your username or root, shouldn’t it be able to see both of these without issue?

Hi @ChuckPa

works if the invoking UID minimally has RX permission.

It’s my understanding that ‘-d’ on a Mac only tests if the directory exists, not whether it’s readable (r) or whether I can cd into the directory (x). An administrator root user does not automatically have that access on a Mac. They will see permission denied if permission is not explicitly given in ls -l

Given PMS runs as your username and then you run the script as your username or root, shouldn’t it be able to see both of these without issue?

If all the parent directories give us permission down that low in the tree, and if there is no case sensitive typo on our part, then yes the test should work. It’s a mystery for me :slight_smile:

So back to the other side of that ??

  1. You run as your username (with ~/Library/Application Support/Plex Media Server beneath you)

  2. You run as root.

If you can see the directory exists, and you’re running the tool, is that not enough?

Given: User ‘chuck’ won’t have a Plex .app but user ‘nibbles’ does (the real server)
Question: What should happen when ‘chuck’ runs?

I think ‘chuck’ should be kicked to the curb :rofl:

The error message might be a little wonky but it’s still a “get out… you don’t belong” LOL

1 Like

Yes I always thought it was enough to see if the directory exists. We should be able to assume their permissions are essentially default / not out of whack.

Yes user chuck, a non-administrator, would get a permissions error trying to check if my Plex DB directory exists.

I hope you can sort it out and it be compatible with Ventura and zsh, Nibbles.

Poor Chuck, he needs First aid :face_with_peeking_eye:

Chuck it was only intended to be a bit of Tongue and Cheek, I could not manage digital First aid. So that is that…

:mask: :mask:

Digital first aid ? as in :point_up: or the other finger? lol

LOL there’s a bar in town that advertises “Digital” beer taps.

… because the bartenders operate the taps with their fingers.

Regarding this MacOS fix,

If I take:

  # Apple Mac
  elif [ -d "/Applications/Plex Media Server.app" ] && \
       [ -d "$HOME/Library/Application Support/Plex Media Server" ]; then

    # Where is the software

and add the test

  # Apple Mac
  elif [ -d "/Applications/Plex Media Server.app" ] && \
       [ -d "$HOME/Library/Application Support/Plex Media Server" ] && \
       [ -w "$HOME/Library/Application Support/Plex Media Server" ]; then

    # Where is the software
  1. Will this work because the tool runs using /bin/sh (not /bin/zsh)
  2. It tests for existence first,
  3. Then confirms it can write to Plex Media Server which implies it can also write to ‘Databases’

Thoughts?

No little birdie here…

helping

Is there a way for DBRepair to check if there is a newer version available?

You can sign up for updates at GitHub, and receive an email when a new version is posted.

2 Likes

Folks,

I’ve finished making corrections & some changes for upcoming v1.0.6

– binhex version independent detection
– MacOS detection

For those who help me out with testing.

I have GHI’s
Issue detecting Binhex following update · Issue #72 · ChuckPa/PlexDBRepair · GitHub

and
MacOS: Incorrect detection in some cases results in 'Cannot write to databases' error · Issue #73 · ChuckPa/PlexDBRepair · GitHub

With open PR: Fixes: Macros priorization & Binhex detection by ChuckPa · Pull Request #74 · ChuckPa/PlexDBRepair · GitHub

I would greatly appreciate extra hands confirming I’ve fixed these two without breaking anything else. :see_no_evil: lol

1 Like

What’s the verdict?

Do the changes (located in the branch) fix the issues and OK to merge (PR #74)?

Checked version 1.0.6 on a physical server running Ubuntu 22.04.2 LTS using …

sudo sh DBRepair.sh stop check status start exit
sudo sh DBRepair.sh stop automatic status start exit

… and everything completed without errors. No concerns with the merge for my use case of the tool. Log file output below for reference in case you want it.

2023-05-30 16.33.35 - ============================================================
2023-05-30 16.33.35 - Session start: Host is Ubuntu 22.04.2 LTS
2023-05-30 16.33.35 - Stop    - PASS
2023-05-30 16.33.43 - Check   - Check com.plexapp.plugins.library.db - PASS
2023-05-30 16.33.51 - Check   - Check com.plexapp.plugins.library.blobs.db - PASS
2023-05-30 16.33.51 - Check   - PASS
2023-05-30 16.33.51 - Start   - PASS
2023-05-30 16.33.51 - Exit    - Delete temp files.
2023-05-30 16.33.51 - Session end. Tue 30 May 2023 16:33:51 IST
2023-05-30 16.33.51 - ============================================================
2023-05-30 16.34.22 - ============================================================
2023-05-30 16.34.22 - Session start: Host is Ubuntu 22.04.2 LTS
2023-05-30 16.34.22 - Stop    - PASS
2023-05-30 16.34.22 - Auto    - START
2023-05-30 16.34.30 - Check   - Check com.plexapp.plugins.library.db - PASS
2023-05-30 16.34.31 - Check   - Check com.plexapp.plugins.library.blobs.db - PASS
2023-05-30 16.34.31 - Check   - PASS
2023-05-30 16.35.22 - Repair  - Export databases - PASS
2023-05-30 16.35.58 - Repair  - Import - PASS
2023-05-30 16.36.07 - Repair  - Verify main database - PASS (Size: 601MB/600MB).
2023-05-30 16.36.07 - Repair  - Verify blobs database - PASS (Size: 376MB/376MB).
2023-05-30 16.36.07 - Repair  - Move files - PASS
2023-05-30 16.36.07 - Repair  - PASS
2023-05-30 16.36.07 - Repair  - PASS
2023-05-30 16.36.08 - Reindex - MakeBackup com.plexapp.plugins.library.db - PASS
2023-05-30 16.36.08 - Reindex - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
2023-05-30 16.36.08 - Reindex - MakeBackup - PASS
2023-05-30 16.36.17 - Reindex - Reindex: com.plexapp.plugins.library.db - PASS
2023-05-30 16.36.18 - Reindex - Reindex: com.plexapp.plugins.library.blobs.db - PASS
2023-05-30 16.36.18 - Reindex - PASS
2023-05-30 16.36.18 - Reindex - PASS
2023-05-30 16.36.18 - Auto    - COMPLETED
2023-05-30 16.36.18 - Start   - PASS
2023-05-30 16.36.18 - Exit    - Delete temp files.
2023-05-30 16.36.18 - Session end. Tue 30 May 2023 16:36:18 IST
2023-05-30 16.36.18 - ============================================================

Thank you.

I’ll merge as soon as I get confirmation for binhex and MacOS

@ChuckPa

Above you asked whether adding that 3rd test would work for sh. Yes.
To be thorough, we expect the directory to exist and have perms rwx
(with the x to be able to cd into the directory).
A test I’ve done is: does it begin with drwx, e.g.

ls -ld "$HOME/Library/Application Support/Plex Media Server"
drwxr-xr-x  16 nibbles  staff  512 Dec 27 19:27 /Users/nibbles/Library/Application Support/Plex Media Server

testing your latest now on MacOS

10.14.6 Mojave
12.6.6 Monterey
13.4 Ventura


EDIT: testing complete. It works on all three, version 1.0.7.

Thanks for finding it was a precedence issue. I couldn’t figure how to reproduce it up till then.

1 Like

What would the exact instructions be to use this tool on a Windows machine?

Also what does this mean?
“100% validity/usability by Plex is not guaranteed as the tool cannot validate each individual record contained in the database. It can only validate at the SQLite level.”

Does that mean that this has a chance to make the repaired database incompatible with Plex?

Use the BAT file .

That’s all that runs for Windows.

It’s a preset sequence (what ‘auto’ does).

Another user is contributing the Powershell version when he gets time to complete it.
I’m not proficient in any of the Windows tools (except format LOL) :slight_smile:

This is clarifying that IF the data in the records (e.g metadata is pointing to the wrong movie or episode) it won’t be able to detect that.

The tool’s fundamental purposes are:

  1. Keep the DB file itself structurally sound so PMS can start (PMS isn’t smart enough to handle DB corruption :roll_eyes:

  2. Optimize the DB at the SQLite level when PMS is stopped to produce a better optimization than PMS ever can (because it’s running).