Commit Graph

45 Commits

Author SHA1 Message Date
John Maguire 341dc7326f Reformat all C++ 2020-09-22 14:56:06 +01: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 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 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 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
Eduardo Sánchez Muñoz 4722477b1e Add full rescan reason for original year tag support. 2015-07-01 15:33:25 +02:00
Arnaud Bienner 946c0381d1 Don't set thread priority in LibraryWatcher constructor, as this is executed in the main thread.
Do it when thread actually starts (create a new Thread class for this purpose).
Fixes #4523.
2015-02-28 16:44:32 +01:00
David Sansome 01ae151f8a Delay writing WMA ratings and play counts until playback has finished. Fixes #3593 2014-06-07 15:29:23 +10:00
David Sansome f6a72828a9 Write statistics and ratings in Library, not LibraryBackend. 2014-06-07 15:19:43 +10:00
John Maguire 3323c2d094 Convert all instances of foreach() to a C++11 for
find ext src -name '*.cpp' -exec \
    sed -i -e 's/foreach(\([^,]\+\),/for (\1 :/' {} \;
2014-02-10 14:43:32 +01:00
John Maguire bebd781fdf Reformat all non-3rd-party C/C++/Objective-C++.
Command line:
find src ext -regex '.*\.\(h\|cpp\|mm\)' -exec clang-format -i
 -style='{BasedOnStyle: Google, DerivePointerBinding: false}' {} \;
2014-02-07 16:34:20 +01:00
David Sansome eaf182a59a Merge pull request #4161 from BrummbQ/master
don't rescan unchanged files if library has been unavailable.  Fixes #3032
2014-02-07 22:45:55 +11:00
John Maguire 71893e4847 Use nullptr instead of NULL everywhere. 2014-02-06 17:29:59 +01:00
Gregor Tätzner 7317b6792e don't rescan unchanged files if library has been unavailable 2014-02-01 20:21:28 +01:00
Arnaud Bienner 88918d45c5 Update issue 1175:
Save rating and statistics in two distinct ways, and let users activate them separately in preferences.
2013-03-30 23:42:29 +01:00
Arnaud Bienner db5fbe2059 Update issue 1175:
Add an option in preferences to save all ratings/statistics into files, for all songs
2013-03-26 23:56:46 +01:00
Arnaud Bienner b157c307e7 Add preference to save ratings and statistics in files 2013-02-24 18:36:37 +01:00
Arnaud Bienner 09596e3732 Don't get stuck when exiting Clementine while library is being created/updated 2012-08-30 00:01:28 +02:00
David Sansome 21fbd40f9f Don't try to initialise the library model until after the grouping settings have been read from the config. Fixes issue 3005 2012-06-16 20:54:08 +01:00
David Sansome ab5ccf69da Refactoring: remove BackgroundThread 2012-02-26 15:05:46 +00:00
David Sansome 48f15c9fc7 Refactoring: instead of passing individual pointers to useful core classes (like TaskManager or LibraryBackend) to each class that uses them, pass one singleton-like Application instance everywhere. 2012-02-26 14:40:51 +00:00
David Sansome d4b4606068 Create the FilesystemWatcherInterface directly in the LibraryWatcher, fixing a crash when trying to add a new device. 2012-01-08 18:37:46 +00:00
John Maguire 9fdfb52225 Use FSEvent-based filesystem watcher on Mac. 2012-01-05 14:51:23 +00:00
David Sansome e6b2e5bcae Make the DeleteSongs function actually delete songs again, and make a new MarkUnavailable function that is called when songs are deleted from disk (and stop it from removing the song from the search index). 2011-07-06 20:07:56 +00:00
Arnaud Bienner 41a4393b24 Translate dynamic playlist names at runtime. 2011-04-19 21:39:02 +00:00
David Sansome 2b08d27a88 Show loading indicators in the library model and the status bar when asynchronously loading songs during initialisation. 2011-02-26 14:27:57 +00:00
Paweł Bara aa6c3ab35b a way to mark DB schema versions as requiring a full library rescan
message dialog for a user when he's reached a full library rescan requiring schema version (like the final one of CUE sheet support)
2011-02-25 20:10:41 +00:00
Paweł Bara 20658989c3 full library rescan feature - should already work as expected 2011-02-17 19:57:14 +00:00
David Sansome f11c494c44 Add a random smart playlist to Jamendo 2010-11-27 19:18:56 +00:00
David Sansome 69d3d89b0f Have a different list of smart playlists for Jamendo and the normal Library. Only add default Jamendo smart playlists once. 2010-11-27 17:52:08 +00:00
David Sansome ed1a25693c Add missing licenses to debian/copyright, and add copyright information to each source file 2010-11-20 13:27:10 +00:00
David Sansome 4750c19d00 Remove the playlists tab and add a smart playlists section to the library view instead 2010-11-17 20:21:04 +00:00
David Sansome d980fd5ff8 Remove the pointless CreateInThread method from BackgroundThread and instead move objects to the right thread after creation. 2010-08-27 18:36:57 +00:00
David Sansome d620779696 Add an option to disable directory watchers 2010-07-10 17:03:28 +00:00
David Sansome 2deca7fd61 Add a DeviceManager which holds all the listers and connected devices. Make FilesystemDevices use their own LibraryWatcher. 2010-06-26 12:41:18 +00:00
David Sansome 05b6c8fe71 Allow organising of whole directories, and pause the library watcher while organising is in progress. 2010-06-24 21:46:18 +00:00
David Sansome f808591ec7 Refactor the loading indicator widget into a seperate TaskManager class that can handle tasks with progress 2010-06-23 13:21:30 +00:00
David Sansome 492d8fec87 Use sqlite's Full Text Search on the songs table 2010-06-20 16:30:10 +00:00
David Sansome c834a5f31f Do the compilation processing in the database thread, and make everything lock on the database to ensure two threads don't access it at once. 2010-06-02 16:22:20 +00:00
David Sansome 03d876a599 Put the Database object in its own thread, and create the Library and Playlist backends in that database thread. The database calls don't happen in the database thread yet, but this is the first step towards making sure sqlite access is thread safe. 2010-06-02 15:58:07 +00:00
David Sansome 3365c7c217 Fix a few memory leaks 2010-05-28 19:51:51 +00:00
David Sansome 0021e5f7e4 Make library scanning on startup optional, and add a menu item to update the library. Fixes issue #341 2010-05-25 20:40:45 +00:00
David Sansome 1aee5e4667 Split all the source files up into seven new directories. 2010-05-10 21:50:31 +00:00