Jump to content

Manually removed folders are not disappearing from library on scan?


Go to solution Solved by adminExitium,

Recommended Posts

Posted
11 hours ago, danergo said:

@Lukesure thing.

Shall I uninstall Emby first to reach a clean database

 

Thank you!

This is the best way if you're willing to do that, yes.

  • 4 weeks later...
Posted (edited)

@LukeI have uninstalled Emby:

 

Quote

sudo apt-get remove emby-server

Then I downloaded the latest BETA, and installed it via:

Quote

sudo dpkg -i ...

However, all settings are libraries were remain intact.

 

I would appreciate now if you could describe how shall I retest this bug.

 

And I have to add: I now tried to uninstall, and I did also remove the `/var/lib/emby` folder.

 

Then after installing, it couldn't start, because it didn't created the `/var/lib/emby` folder. After I manually creating that folder and gave the correct ownership and permissions, Emby could start. Strange, because I used `sudo dpkg -i` to install it.

 

Cheers

Edited by danergo
Posted

Okay, retested with latest available BETA.

Still not working they way IMHO it should:

Quote

When a library gets unavailable, just hide it

I added the SD card's path, then did a rescan. It contained 1 video file. It appeared immediately.

Then I've ejected the SD card and did another rescan. See my screenshot. "SD Card" shall be hidden when all of its library paths are invalid:

2025-11-07 13:46:49.677 Info App: ValidatePhysicalRoots start validating 17 DCIM /media/OsmoPocket3/DCIM
2025-11-07 13:46:49.684 Error App: Error in validateChildren for 17 /media/OsmoPocket3/DCIM
	*** Error Report ***
	Version: 4.9.2.6
	Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_arm64.deb
	Operating system: Linux version 6.1.99 (fa@jensen) (aarch64-linux-gcc (ctng-1.26.0-129g-FA) 14.2.0, GNU ld (GNU Binutils) 2.43.1) #33 SMP Tue Jan 21 11:32:39 CST 2025
	OS/Process: arm64/arm64
	Framework: .NET 8.0.11
	Runtime: opt/emby-server/system/System.Private.CoreLib.dll
	Processor count: 4
	Data path: /var/lib/emby
	Application path: /opt/emby-server/system
	System.IO.DirectoryNotFoundException: System.IO.DirectoryNotFoundException: Could not find a part of the path '/media/OsmoPocket3/DCIM'.
	   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
	   at System.IO.DirectoryInfo.InternalEnumerateInfos(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
	   at Emby.Server.Implementations.IO.ManagedFileSystem.EnumerateFileSystemInfos(DirectoryInfo dir, Boolean recursive)
	   at Emby.Server.Implementations.IO.ManagedFileSystem.GetFileSystemEntries(String path, Boolean recursive, FileSystemCredentials credentials)
	   at MediaBrowser.Controller.Providers.DirectoryService.GetFileSystemEntriesInternal(String path)
	   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
	   at MediaBrowser.Controller.Entities.BaseItem.GetFileSystemChildren(IDirectoryService directoryService)
	   at MediaBrowser.Controller.Entities.Folder.GetNonCachedChildren(IDirectoryService directoryService, BaseItem[] collectionFolders, LibraryOptions libraryOptions)
	   at MediaBrowser.Controller.Entities.BaseItem.ValidateChildrenInternal(IProgress`1 progress, CancellationToken cancellationToken, Boolean recursive, Boolean refreshChildMetadata, BaseItem[] collectionFolders, LibraryOptions libraryOptions, Dictionary`2 newItemIds, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
	   at Emby.Server.Implementations.Library.LibraryManager.ValidatePhysicalRoots(IProgress`1 progress, IDirectoryService directoryService, CancellationToken cancellationToken)
	Source: System.Private.CoreLib
	TargetSite: Void Init()

As you can see here, we get a massive and pretty simply-solvable error here.

I wish:

  1. `validateChildren` to return FALSE when folder is not found. I.e. don't crash to error, just return FALSE.
  2. `ValidatePhysicalRoots` to return FALSE, when all `validateChildren` return FALSE. I.e `ValidatePhysicalRoots` shall return TRUE if there is ANY valid child.
  3. On "Home" screen, display only libraries having `ValidatePhysicalRoots` as TRUE by default (or adding a new item to library setting: hide is invalid)

The problem now is, that old files remain in unavaliable media items as cache, and doesn't gets cleared - maybe because of this error.

I'm also attaching the logfile, but it doesn't contain much more valuable info.

Screenshot 2025-11-07 164845.png

embyserver (11).txt

Posted

@danergothe library does not get hidden/removed unless you remove it from Emby library setup.

Does that answer your question?

Posted
3 hours ago, Luke said:

@danergothe library does not get hidden/removed unless you remove it from Emby library setup.

Does that answer your question?

Hi, @Luke,

Yes it answers; however I wish it to be auto-hide as per my previous post.

It would be extremely useful, and very easy to solve in beta. I can also write it as a PR.

GrimReaper
Posted

I would imagine that to be a troubleshooting nightmare, with libraries popping on and off of their own volition and users jumping on forums "My library has disappeared!" 

  • Agree 1
Posted
1 minute ago, GrimReaper said:

I would imagine that to be a troubleshooting nightmare, with libraries popping on and off of their own volition and users jumping on forums "My library has disappeared!" 

My proposition was included:

A new option for libraries: "hide if invalid".

That could be disabled by default, i.e. NOT hide even if its invalid.

So it will not cause any "troubleshooting nightmare" IMHO. (We just have to add a line to log: library X is not showing because all items are invalid).

For me it seems much worse to have a library full of invalid thumbnails and folder structures from which none can be opened.

GrimReaper
Posted
10 minutes ago, danergo said:

For me it seems much worse to have a library full of invalid thumbnails and folder structures from which none can be opened.

My assumption (not necessarily correct one, by any means) is that 99% of users prefer it that way as it'd indicate issue(s) with their mount points/network drives, which is way more common setup that SD cards inserting/removing. 

But that is completely up to the Devs, you are always welcome to open a Feature Request topic in the respective forum section, as an option it surely cannot hurt, it might get some traction, time will tell. 

  • Like 1
  • Solution
adminExitium
Posted (edited)

One possible workaround is to use something like mergerfs (https://trapexit.github.io/mergerfs/latest/) and merge your multiple library roots into a single mount-point and add that to Emby. mergerfs can deal with disappearing and reappearing branches just fine (https://trapexit.github.io/mergerfs/latest/error_handling_and_logging/#branches-disappearing-reappearing), just note that Emby will be continuously deleting and adding items from that branch when it disappears and reappears respectively.

Edited by adminExitium
  • Thanks 1
Posted
32 minutes ago, adminExitium said:

One possible workaround is to use something like mergerfs (https://trapexit.github.io/mergerfs/latest/) and merge your multiple library roots into a single mount-point and add that to Emby. mergerfs can deal with disappearing and reappearing branches just fine (https://trapexit.github.io/mergerfs/latest/error_handling_and_logging/#branches-disappearing-reappearing), just note that Emby will be continuously deleting and adding items from that branch when it disappears and reappears respectively.

Wow, that would definitely make sense!

I'm gonna test this and come back.

Posted

This was not an easy ride, but finally I managed to make this work with @adminExitium's answer.

Perfect now! SD Card folder is empty when there is no SD card inserted, and it gets populated when there is a card presented (on library scans).

I can use Emby to delete wrong/irrelevant media files from SD cards :)

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...