CollectionWatcher: Only start transaction with scan on startup
Fixes #1469
This commit is contained in:
parent
17e88bb97d
commit
ff6e93fc15
|
@ -421,22 +421,26 @@ void CollectionWatcher::AddDirectory(const CollectionDirectory &dir, const Colle
|
||||||
last_scan_time_ = QDateTime::currentSecsSinceEpoch();
|
last_scan_time_ = QDateTime::currentSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We can do an incremental scan - looking at the mtimes of each subdirectory and only rescan if the directory has changed.
|
if (monitor_) {
|
||||||
ScanTransaction transaction(this, dir.id, true, false, mark_songs_unavailable_);
|
for (const CollectionSubdirectory &subdir : subdirs) {
|
||||||
QMap<QString, quint64> subdir_files_count;
|
AddWatch(dir, subdir.path);
|
||||||
const quint64 files_count = FilesCountForSubdirs(&transaction, subdirs, subdir_files_count);
|
}
|
||||||
transaction.SetKnownSubdirs(subdirs);
|
}
|
||||||
transaction.AddToProgressMax(files_count);
|
if (scan_on_startup_) {
|
||||||
for (const CollectionSubdirectory &subdir : subdirs) {
|
// We can do an incremental scan - looking at the mtimes of each subdirectory and only rescan if the directory has changed.
|
||||||
if (stop_requested_ || abort_requested_) break;
|
ScanTransaction transaction(this, dir.id, true, false, mark_songs_unavailable_);
|
||||||
|
QMap<QString, quint64> subdir_files_count;
|
||||||
if (scan_on_startup_) ScanSubdirectory(subdir.path, subdir, subdir_files_count[subdir.path], &transaction);
|
const quint64 files_count = FilesCountForSubdirs(&transaction, subdirs, subdir_files_count);
|
||||||
|
transaction.SetKnownSubdirs(subdirs);
|
||||||
if (monitor_) AddWatch(dir, subdir.path);
|
transaction.AddToProgressMax(files_count);
|
||||||
|
for (const CollectionSubdirectory &subdir : subdirs) {
|
||||||
|
if (stop_requested_ || abort_requested_) break;
|
||||||
|
ScanSubdirectory(subdir.path, subdir, subdir_files_count[subdir.path], &transaction);
|
||||||
|
}
|
||||||
|
if (!stop_requested_ && !abort_requested_) {
|
||||||
|
last_scan_time_ = QDateTime::currentSecsSinceEpoch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
last_scan_time_ = QDateTime::currentSecsSinceEpoch();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit CompilationsNeedUpdating();
|
emit CompilationsNeedUpdating();
|
||||||
|
|
Loading…
Reference in New Issue