TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nicotine-plus/nicotine-plus/llms.txt
Use this file to discover all available pages before exploring further.
Shares class manages file sharing functionality, including scanning shared folders, building file indexes, and handling share requests.
Overview
The Shares module is responsible for:- Scanning and indexing shared folders
- Managing shared file databases
- Handling file search queries
- Computing share statistics
- Processing buddy-only shares
Shares Class
Initialization
Core Methods
rescan_shares()
Rescans all shared folders and rebuilds the file index.Whether this is an initial scan on startup
Whether to perform a rescan of shared folders
Whether to rebuild the entire share database from scratch
Whether to run the scan in a separate thread
Force rescan even if shares haven’t changed
Rescanning can take significant time for large share collections. The scan runs in a separate thread by default to avoid blocking.
convert_shares()
Converts shared folder paths to the internal format.List of folder paths to convert
The virtual name for the shared folder
The actual filesystem path
get_shared_folders()
Returns the list of currently shared folders.List of tuples containing (virtual_name, actual_path)
get_compressed_shares_message()
Generates a compressed representation of shared files for sending to peers.Type of shares: “normal” or “buddy”
Compressed file list message ready to send
Search Methods
search_files()
Searches shared files for a given query.The search query string
Maximum number of results to return
Search mode: 0=global, 1=buddy, 2=rooms, 3=user
Set of words to exclude from results
List of matching files with metadata
file_is_shared()
Checks if a specific file is shared.Username requesting the file
Virtual path of the file
True if file is shared and accessible to the user
Statistics Methods
get_num_shared_folders()
Returns the number of shared folders.get_num_shared_files()
Returns the total number of shared files.get_compressed_shares_size()
Returns the size of the compressed shares database.Type of shares: “normal” or “buddy”
Share Configuration
Shared Folder Structure
Shared folders are configured as tuples:Buddy Shares
Buddy-only shares are only accessible to users on your buddy list:File Attributes
The Shares module automatically extracts metadata from shared files:Events
The Shares module emits several events during operation:Complete Example
Best Practices
- Rescan shares periodically to keep the index up to date
- Use buddy shares for content you only want to share with trusted users
- Monitor scan progress for large share collections
- Handle scan events to update UI progress indicators
- Cache search results to avoid repeated scans