Repository navigation
Keep Unraid's stored Docker order equal to the folder view, so the order survives without the plugin - #135
Open
luuvasara wants to merge 1 commit into
Open
Keep Unraid's stored Docker order equal to the folder view, so the order survives without the plugin#135luuvasara wants to merge 1 commit into
luuvasara wants to merge 1 commit into
Conversation
syncNativeDockerOrder() writes the order the Docker tab shows (folders first, each folder as one run, then the rest in Unraid's order) to dockerMan/userprefs.cfg in Unraid's format, under Unraid's lock. New containers go last, oldest first. Nothing is written when the order is already equal, the list can't be read, or there are no folders and no stored order. Removing the plugin keeps the same order as a flat list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related pull requests
Summary
FolderView Plus writes the order it shows into Unraid's own stored Docker order,
/boot/config/plugins/dockerMan/userprefs.cfg. Each folder is written as one contiguous run: thefolder-<id>entry, its members in folder order, then its child folders. After the folders come the containers outside folders, in Unraid's order. The plugin then only groups an order that Unraid holds. Removing the plugin, or turning folders off, leaves the containers in the same order as one flat list.The principle: Unraid owns the order, FolderView Plus only groups it
The container order is Unraid's. It is the start order (Unraid starts containers one by one in the order of its autostart file, which follows
userprefs.cfg: https://github.com/unraid/webgui/blob/99e39027fbd50cf8c3768da0464bdd8de754a7f7/etc/rc.d/rc.docker#L712-L736), and it has to be right with or without any plugin. That is not a preference: a dependency has to start before and stop after what needs it, the rule systemd, Docker Compose and Kubernetes apply. Sources and the failures a wrong order causes are in unraid/webgui#2844. A folder is a group within that order, not a second order. Example data:When the order inside a folder changes, the stored order changes the same way. Without the folders, the result is the same order. Unraid ignores the
folder-…lines because they are not container names.Why: what happens today
userprefs.cfg(comment in lib.docker-order.php: "userprefs.cfg is not written here; Unraid owns drag-order persistence",FolderView-Plus/src/folderview.plus/usr/local/emhttp/plugins/folderview.plus/server/lib.docker-order.php
Line 55 in e7e000d
userprefs.cfgdoes not list at the top:array_search()returnsfalse(https://www.php.net/manual/en/function.array-search.php), which ties with position 0 and sorts before every other position (https://www.php.net/manual/en/language.operators.comparison.php). FolderView Plus puts them last. So a container can jump many rows between the two views.What changes
syncNativeDockerOrder()in lib.docker-order.php builds the order shown on the tab: folders first, then the rest in Unraid's order. It writes that touserprefs.cfgin Unraid's own format (0="name"lines). It runs:syncContainerOrder('docker'), in every start-order mode including "unmanaged";/var/lock/docker-userprefs.lock), so a drag on the Docker tab and this sync cannot overwrite each other./boot/config/plugins/dockerManis added to the allowed write paths in lib.filesystem-security.php, foruserprefs.cfgonly.How it fits with Unraid
A matching change for Unraid (unraid/webgui#2844) makes Unraid keep one stored order. It gives every new container a position at the end, and makes the Docker tab, Dashboard and autostart read it the same way. It takes the same lock.
None of these combinations is worse than today, so either PR can be merged first.
Testing
Tested on an Unraid 7.4 test server with Unraid unpatched and patched:
Screenshots
The order with and without FolderView Plus (Unraid 7.4 test server, example containers
ord-*):Left: the folder
ord-folderholds ord-m, ord-new2 and ord-new3, between ord-renamed and plex. Right: the same server after removing the plugin: ord-z, ord-renamed, ord-m, ord-new2, ord-new3, plex. The folder is gone and the order stays. These are from an earlier test round, where a folder kept the place it was dragged to; the final version puts folders first, as FolderView Plus draws them.Folders first, and the Dashboard agrees (previous version of this patch; the last change, new containers oldest first, does not affect what these show):
The folder
ord-facomes first, then ord-b3, plex, bazarr, emby, nginx… The Dashboard tile, which reads Unraid's stored order, shows the same sequence.This change was written with the help of frontier AI. I reviewed and tested it.