mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-11 12:51:03 +00:00
- Fix a crash when scanned directory does not exist
This commit is contained in:
parent
a2792efa72
commit
0485864d38
@ -1044,6 +1044,11 @@ void bittorrent::saveTrackerFile(QString hash) {
|
|||||||
// Enable directory scanning
|
// Enable directory scanning
|
||||||
void bittorrent::enableDirectoryScanning(QString scan_dir) {
|
void bittorrent::enableDirectoryScanning(QString scan_dir) {
|
||||||
if(!scan_dir.isEmpty()) {
|
if(!scan_dir.isEmpty()) {
|
||||||
|
QDir newDir(scan_dir);
|
||||||
|
if(!newDir.exists()) {
|
||||||
|
qDebug("Scan dir %s does not exist, create it", scan_dir.toUtf8().data());
|
||||||
|
newDir.mkpath(scan_dir);
|
||||||
|
}
|
||||||
if(FSWatcher == 0) {
|
if(FSWatcher == 0) {
|
||||||
FSMutex = new QMutex();
|
FSMutex = new QMutex();
|
||||||
FSWatcher = new QFileSystemWatcher(QStringList(scan_dir), this);
|
FSWatcher = new QFileSystemWatcher(QStringList(scan_dir), this);
|
||||||
@ -1051,8 +1056,11 @@ void bittorrent::enableDirectoryScanning(QString scan_dir) {
|
|||||||
// Initial scan
|
// Initial scan
|
||||||
scanDirectory(scan_dir);
|
scanDirectory(scan_dir);
|
||||||
} else {
|
} else {
|
||||||
QString old_scan_dir = FSWatcher->directories().first();
|
QString old_scan_dir = "";
|
||||||
|
if(!FSWatcher->directories().empty())
|
||||||
|
old_scan_dir = FSWatcher->directories().first();
|
||||||
if(old_scan_dir != scan_dir) {
|
if(old_scan_dir != scan_dir) {
|
||||||
|
if(!old_scan_dir.isEmpty())
|
||||||
FSWatcher->removePath(old_scan_dir);
|
FSWatcher->removePath(old_scan_dir);
|
||||||
FSWatcher->addPath(scan_dir);
|
FSWatcher->addPath(scan_dir);
|
||||||
// Initial scan
|
// Initial scan
|
||||||
|
Loading…
x
Reference in New Issue
Block a user