Library cleared when external drive not connected
-
I have my library on an external SSD.
If I forget to connect it before starting Strawberry, my library is cleared (I have update library at start).
I have to do full a full rescan.
An error message should warn that the specified location is not found and either exit or retry.
ThanksPS: I already posted this elsewhere but got no useful reply
-
The thing is, we would need "a library of libraries"
The way POSIX filesystem's work are different than LABEL names like
C: D: E:
in windows environments. Everything in POSIX is like a File, and a directory can be 1) a directory in the filesystem 2) a mount point, that points to a device or another bind, another filesystem or even a remote storage.
The way Strawberry works is by searching the paths for the files, the Library is a set of paths, not a set of DEVICES;we would need to make a library of DEVICES, so that Strawberry detects this device is not mounted, for what you are asking to work.
Another possibility would be to create a "smart test" that if it had several files in the DB but now finds nothing, then prompt the user for plugging something or perphaps make the user choose to abort. Kinda something like that, before rescanning: "Your library seems wiped out, do you want to proceed or abort? Make sure you have plugged any external storage or mounted any remote storage before proceeding."
I'm sorry if you tought my message for you was useless, but actually that was a solution for your rescanning problem, anyway.
-
Thanks Gustavo for replying, but I am surprised it looks so complicated to see if a folder is available.
The source folder must be stored somewhere as it can be scanned for changes at start.This my Library backup script in Unix:
source="/media/Jean-Luc/JukeBox Master"
test -d "$source"
retval="$?"
if [ "$retval" -ne 0 ]; then
echo "Dossier '$source' non trouvé" (not found)
exit 1
fiI check that it is connected before doing anything.
Surely the same logic can be applied to Strawberry, even in Windows. -
@jonas can you help me finish this? I belive i'm not Exit() properly as we should in the application, i'm doing a pretty forced exit. I''m having problems with the threaded situation also had errors with the painter so I tried to move the message box to the main thread, dunno if this is correct.
void CollectionWatcher::PerformScan(const bool incremental, const bool ignore_mtimes) { stop_requested_ = false; for (const CollectionDirectory &dir : std::as_const(watched_dirs_)) { if (stop_requested_ || abort_requested_) break; ScanTransaction transaction(this, dir.id, incremental, ignore_mtimes, mark_songs_unavailable_); CollectionSubdirectoryList subdirs(transaction.GetAllSubdirs()); if (subdirs.isEmpty()) { qLog(Debug) << "Collection directory wasn't in subdir list."; CollectionSubdirectory subdir; subdir.path = dir.path; subdir.directory_id = dir.id; subdirs << subdir; } QMap<QString, quint64> subdir_files_count; quint64 files_count = FilesCountForSubdirs(&transaction, subdirs, subdir_files_count); if (!files_count) { qLog(Debug) << "Directory" << dir.path << " is empty. Prompting user before continuing."; emit CollectionDirectoryIsEmpty(dir.path); } transaction.AddToProgressMax(files_count); for (const CollectionSubdirectory &subdir : std::as_const(subdirs)) { if (stop_requested_ || abort_requested_) break; ScanSubdirectory(subdir.path, subdir, subdir_files_count[subdir.path], &transaction); } } last_scan_time_ = QDateTime::currentSecsSinceEpoch(); emit CompilationsNeedUpdating(); } void CollectionWatcher::CollectionDirectoryIsEmpty(QString directory) { // Moved to main thread using QMetaObject QMetaObject::invokeMethod(qApp, [directory, this] { QMessageBox::StandardButton reply; reply = QMessageBox::question(nullptr, tr("Collection directory is empty!"), tr("Strawberry could not find any files in directory '%1' of your collection. Check that you have plugged any device properly or connected any remote storage. Continue anyway?") .arg(directory), QMessageBox::Abort | QMessageBox::Ok); if (reply == QMessageBox::Abort) { exit(1); } }); }
Also the way I did maybe its not even blocking the scan after the "emit"
edit: Yep, now I can see that I did figured out all wrong where to implement this....
-
@Gustavo-L-Conte
I think it would be better to check dirs, not subdirs, I think it should be possible withQStorageInfo
to check if it's mounted.
And GUI stuff should never be in CollectionWatcher.
But I'm not a fan of this solution, a popup message seems unnecessary. If you have 2 collection directories, songs for the one missing shouldn't be shown so marking song unavailable like it's already done seem like the best solution, but checking ctime when the songs are found again to avoid any rescan, and perhaps use GIO to detect when the drive is mounted again. -
Hello Gustavo & Jonas,
Thank you for looking at this problem.
This is not a major bug preventing me from using Strawberry, but just annoying.
I know how to get round the problem but I am not sure my sister or some of my friends would.
This could deter them from using it.