Commit Graph

407 Commits

Author SHA1 Message Date
Jim Broadus f4e70face1 library: Fix rescan in case where library directory was recreated
If a root library directory is deleted and recreated, it is not
detected since inotify would need to watch the parent directory. On
rescan, if the subdirectory list for a directory is empty, re-add the
library's root directory.

This is an edge case on Linux systems. The issue may not exist on other
operating systems.
2021-04-01 14:53:49 +01:00
Jim Broadus fd3a2a2f12 library: Add accessors to directory structures
Add const accessors to the Directory and Subdirectory structures.
2021-04-01 14:53:49 +01:00
Jim Broadus 3bd15aea0d library: Add option to ignore files by extension
Add a new skip option in library settings that takes a comma separated
list of file extensions. Skip files with the specified extensions when
scanning the library.
2021-03-14 14:00:03 +00:00
John Maguire 341dc7326f Reformat all C++ 2020-09-22 14:56:06 +01:00
Jim Broadus ad882cc999 Add static IsTypeSupported methods to playlist item classes 2020-06-23 11:06:06 +01:00
Jim Broadus f563b7da40 Add DbPlaylistItem base class to LibraryPlaylistItem
This will be used to move items from non-library databases away from the
LibraryPlaylistItem class.
2020-06-19 11:18:32 +01:00
Jim Broadus a22af31e6e Add a common LibraryBackend::Init method.
Most users of LibraryBackend pass empty strings for directory and subdirectory
tables, so add a second Init method that omits those.
2020-03-24 14:10:43 +00:00
Jim Broadus b9f57c574f Add QString version of GetRelativePathToClementineBin.
Avoid converting paths to and from URLs when calling this function.
2020-02-12 09:53:12 +00:00
Jim Broadus ba4320859d Change LibraryDirectoryModel to take shared backend pointer.
This is mainly for parity amongst the library model classes.
2020-02-11 08:09:22 +00:00
Jim Broadus bc99ff80a9 Move LibraryDirectoryModel out of LibraryModel.
There are several instances of the LibraryModel class used in the system. Each
of these creates a LibraryDirectoryModel instance, but only the instance held
by the main library is every used. Move this out of the LibraryModel class and
into the Library class.
2020-02-11 08:09:22 +00:00
Jim Broadus 18a08e87c2 Add a directory_model accessor to Application class. 2020-02-11 08:09:22 +00:00
Jim Broadus feaca363a7 Remove directory by id.
Eliminate need to create temporary Directory object when removing a directory.
2020-01-25 18:22:16 -08:00
Jim Broadus 1c6e43509c Cancel scan when directory is removed.
When a directory is removed from the library during a scan, the scan continues
until complete. This change cancels the scan immediately, unblocking the watcher
thread, then signals the watcher to remove the directory.

A second issue occurs when a previously scanned device is removed during a
scan. All remaining files will be marked as deleted. This change mitigates
this issue, but a timing hole still remains here.
2020-01-24 10:28:51 -08:00
Jim Broadus c40a1f7738 Pass album_art map to ImageForSong as pointer instead of reference.
Requested as part of PR 6543.
2020-01-23 09:15:39 -08:00
Jim Broadus 4ebd3c8c0a Add ability to cancel scan per directory.
Store a boolean along with watched directories to indicate active. Use this flag
to provide a mechanism to halt scans on a per-directory basis.
2020-01-23 09:15:36 -08:00
Jim Broadus 52c3ce70ea Pass a Directory reference to ScanTransaction instead of a directory id.
This is can be done without protecting the directory reference since the method
that removes directories from the watch list is only called on the same thread
as the scan, and never during the life of the ScanTransaction object.
2020-01-21 17:27:01 -08:00
John Maguire d15777ea15
Merge pull request #6537 from jbroadus/scan-sanity-check
Prevent runaway cover art searches.
2020-01-19 17:12:13 +00:00
Jim Broadus 1484afb038 Prevent runaway cover art searches.
When scanning a device such as a mobile phone, it's likely that a directory
containing both image and audio files will be found. Besides the appearance of a
hung scan, it's unlikely that a relevant image will be found.

In the case where filters for relevant filenames don't yield results, set a
sanity limit on the number of images. If the list size is beyond than that
threshold, return an empty path.
2020-01-18 22:46:24 -08:00
Jim Broadus 9e40c5e1a9 Fix hung progress indicator on device disconnect.
When a device is removed during a scan, the scan is cancelled, but the task is
not set to finished.
2020-01-18 20:32:41 -08:00
Jim Broadus 34a2e86b4b Handle FileSystemWatcherInterface::AddPath errors.
On Linux systems, failure to watch a path may be caused by the limit set in
/proc/sys/fs/inotify/max_user_watches. This can be demonstrated by creating
a directory with a large number of empty subdirectories and adding that test
directory as a library.

Check that a file is readable before adding a watch. If adding the watch fails,
report the error to the user only once. Only add the path to subdir_mapping_
if watch succeeds.
2020-01-17 16:26:09 -08:00
Jim Broadus 6a9276ec0a Fix LibraryModel async query crash.
A LibraryBackend may be deleted while an associated LibraryModel object is using
it. An example is an async query running while a connected device is removed.
To prevent this, use a share pointer for the LibraryBackend.

This fixes one case where LibraryBackend is used after deletion. However, the
raw pointer is still passed around in several other places. These should be
evaluated on a case-by-case basis to insure that circular depencencies aren't
introduced.
2020-01-14 21:47:31 -08:00
Jim Broadus f817e0de48 Prevent deletion of LibraryModel object while async query is running.
Create a thread pool for each LibraryModel object and block destruction until
all threads that are operating on this object are complete.

Note that this is not a complete solution. The async query also uses the library
backend which may still be deleted before the thread exits. This will be
addressed in a future change.
2020-01-12 12:24:21 -08:00
John Maguire 10e807dd7d
Merge pull request #6509 from jonaski/tolist
Replace QSet::toList() with QSet::values()
2020-01-05 15:13:33 +00:00
John Maguire 5123d1dd37
Merge pull request #6505 from jonaski/fallthrough
Add fallthrough comment where fallthrough is intended
2020-01-05 00:30:24 +00:00
John Maguire a240818b6c
Merge pull request #6501 from jonaski/compilations
Fix songs stuck in various artists
2020-01-05 00:28:15 +00:00
Jonas Kvinge 5eb32b33c1 Replace QSet::toList() with QSet::values() 2020-01-05 00:58:33 +01:00
Jonas Kvinge 39cdb7fc3f Add fallthrough comment where fallthrough is intended 2020-01-04 23:29:19 +01:00
Jonas Kvinge 39934dc302 Fix songs stuck in various artists 2020-01-04 18:27:42 +01:00
Jonas Kvinge 651965b905 Fix formatting 2020-01-04 18:12:44 +01:00
Jonas Kvinge 250b5ca0a6 Remove pixmap cache and pending art when removing parent nodes instead 2020-01-04 18:07:34 +01:00
Cesar Enrique Garcia Dabo f5ec88b529 Add support in GetConfigPath() for /pixmapcache directory 2019-12-07 23:30:14 +01:00
John Maguire 142f9f26c5
Merge pull request #6454 from jonaski/albumartist
Change remaining group by defaults to album artist
2019-11-13 23:11:16 +00:00
Jonas Kvinge cdfc059cb1 Change remaining group by defaults to album artist 2019-11-13 20:20:44 +01:00
Jonas Kvinge 44c111941c Fix updating song count 2019-11-13 19:20:17 +01:00
John Maguire 21848d62d8
Merge pull request #6450 from jonaski/compilations
Fix updating compilations
2019-11-13 18:01:29 +00:00
Jonas Kvinge 6accd1e3db Fix formatting 2019-11-13 17:39:29 +01:00
Jonas Kvinge 8d75f321de Fix updating compilations 2019-11-13 17:25:54 +01:00
John Maguire 50663ddde0
Merge pull request #6448 from jonaski/librarywatcher
Remove watch for removed subdirectories
2019-11-12 19:57:16 +00:00
Jonas Kvinge ca18a5584d Fix formatting 2019-11-12 20:05:53 +01:00
Jonas Kvinge fd35f20d26 Remove watch for removed subdirectories 2019-11-12 19:55:48 +01:00
Jonas Kvinge 1b35d3f6a3 Dont clear pixmap cache on model reset 2019-11-12 19:26:52 +01:00
Jonas Kvinge 796fa285f5 Fix formatting 2019-11-12 19:16:22 +01:00
Jonas Kvinge 04baa9ec0f Remove album from pixmap cache when song is removed from library model 2019-11-12 19:08:42 +01:00
John Maguire b7c3173001
Merge pull request #6439 from jonaski/signalmapper
Replace all uses of QSignalMapper with C++11 lambda expressions
2019-11-10 19:13:31 +00:00
Jonas Kvinge 344023e6dd Fix formatting 2019-11-10 15:16:39 +01:00
Jonas Kvinge ba31c755ef Replace all uses of QSignalMapper with C++11 lambda expressions 2019-11-10 15:07:12 +01:00
Jonas Kvinge d09c27f719 Remove extra ';' 2019-11-10 00:30:18 +01:00
Jonas Kvinge 1a2274bd2b Merge branch 'master' into qt5-update 2019-07-21 14:20:59 +02:00
James D. Smith bd89a1d2de Fixes for APE filetype. 2019-04-01 22:56:50 -06:00
Jim Broadus 248f1d8596 Prevent UI hang during device scan. (#6291)
When unmounting a device, the ConnectedDevice object is destroyed. The
FileSystemDevice destructor waits on its worker thread. If a scan is in
progress, this will block until completion.

There is an existing Stop method in the LibraryWatcher class that is intended to
stop long running operations. To fix, or at least significantly shorten this
hang, we'll call this before waiting for the thread to exit. Also add a
stop_requested check in the cover art scan.

In addition, add a call to Stop in the Library destructor, which has a similar
usage.
2019-02-20 19:03:44 +11:00