|
|
@ -924,12 +924,21 @@ void bittorrent::setDefaultSavePath(QString savepath) { |
|
|
|
// 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()) { |
|
|
|
Q_ASSERT(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); |
|
|
|
connect(FSWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(scanDirectory(QString))); |
|
|
|
connect(FSWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(scanDirectory(QString))); |
|
|
|
// Initial scan
|
|
|
|
// Initial scan
|
|
|
|
scanDirectory(scan_dir); |
|
|
|
scanDirectory(scan_dir); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
QString old_scan_dir = FSWatcher->directories().first(); |
|
|
|
|
|
|
|
if(old_scan_dir != scan_dir) { |
|
|
|
|
|
|
|
FSWatcher->removePath(old_scan_dir); |
|
|
|
|
|
|
|
FSWatcher->addPath(scan_dir); |
|
|
|
|
|
|
|
// Initial scan
|
|
|
|
|
|
|
|
scanDirectory(scan_dir); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|