Browse Source

- Folder Scanning: initial import of the torrents inside is fixed

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
3c6635cdbe
  1. 3
      src/bittorrent.cpp
  2. 8
      src/filesystemwatcher.h

3
src/bittorrent.cpp

@ -1249,8 +1249,9 @@ void Bittorrent::enableDirectoryScanning(QString scan_dir) {
} }
if(FSWatcher == 0) { if(FSWatcher == 0) {
// Set up folder watching // Set up folder watching
FSWatcher = new FileSystemWatcher(scan_dir, this); FSWatcher = new FileSystemWatcher(this);
connect(FSWatcher, SIGNAL(torrentsAdded(QStringList&)), this, SLOT(addTorrentsFromScanFolder(QStringList&))); connect(FSWatcher, SIGNAL(torrentsAdded(QStringList&)), this, SLOT(addTorrentsFromScanFolder(QStringList&)));
FSWatcher->addPath(scan_dir);
} else { } else {
QString old_scan_dir = ""; QString old_scan_dir = "";
if(!FSWatcher->directories().empty()) if(!FSWatcher->directories().empty())

8
src/filesystemwatcher.h

@ -139,6 +139,7 @@ public:
} else { } else {
#endif #endif
// Normal mode // Normal mode
qDebug("FS Watching is watching %s in normal mode", path.toLocal8Bit().data());
QFileSystemWatcher::addPath(path); QFileSystemWatcher::addPath(path);
scanFolder(); scanFolder();
#ifndef Q_WS_WIN #ifndef Q_WS_WIN
@ -165,11 +166,14 @@ public:
protected slots: protected slots:
// XXX: Does not detect file size changes to improve performance. // XXX: Does not detect file size changes to improve performance.
void scanFolder() { void scanFolder() {
qDebug("Scan folder was called");
QStringList torrents; QStringList torrents;
if(watch_timer) if(watch_timer) {
torrents = watched_folder.entryList(filters, QDir::Files, QDir::Unsorted); torrents = watched_folder.entryList(filters, QDir::Files, QDir::Unsorted);
else } else {
torrents = QDir(QFileSystemWatcher::directories().first()).entryList(filters, QDir::Files, QDir::Unsorted); torrents = QDir(QFileSystemWatcher::directories().first()).entryList(filters, QDir::Files, QDir::Unsorted);
qDebug("FSWatcher: Polling manually folder %s", QFileSystemWatcher::directories().first().toLocal8Bit().data());
}
if(!torrents.empty()) if(!torrents.empty())
emit torrentsAdded(torrents); emit torrentsAdded(torrents);
} }

Loading…
Cancel
Save