The next logical step now is to add proper downloads resuming and partial torrent handling (where some files are missing), as we now have the neccesery backends for that. But first, let's simplify the BT module class system slightly.
One idea when implementing the cache manager last night was also to put it into separate class, as yet another abstraction, however it turned out it was much better to merge it directly into the virtual files layer (which is an abstraction on it's own already). Same pattern should be applied to two more, already existing classes in BT module - Manager, and the newly-added TorrentDb. Neither of them have any big responsibilities that would justify having them as separate Singletons - TorrentDb just contains a map of torrents found in cache folder, and Manager basically just controls the listening port, and currently active torrents. Both of those classes should be moved to the BitTorrent class (the module's main class, derived from ModuleBase).
Once that's done, we can add a nice and clean loop in BitTorrent class, which loops over shared files, checks if it has any torrent associations (via metadata->customdata field), creates the torrent (if it doesn't exist), or attaches the file to existing torrent.
With this in place, the overall bt module class system stays within the
original design graph - the addition of TorrentDb and BitTorrent classes broke away from that design, which causes unnecesery amount of files/classes in the module.
Madcat, ZzZz