From c03b2bbc8710cf39477a429b52f9778c2757edf8 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Fri, 29 Nov 2013 16:15:26 +0100 Subject: [PATCH] Make unblacklisting depending on Up or Download Compare modtime in case of uploading and ETag in case of downloading as they are the correct indicators. --- src/mirall/csyncthread.cpp | 49 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/mirall/csyncthread.cpp b/src/mirall/csyncthread.cpp index 27ad29711..99ca1d045 100644 --- a/src/mirall/csyncthread.cpp +++ b/src/mirall/csyncthread.cpp @@ -199,31 +199,41 @@ bool CSyncThread::checkBlacklisting( SyncFileItem *item ) // if there is a valid entry in the blacklist table and the retry count is // already null or smaller than 0, the file is blacklisted. if( entry.isValid() ) { + item->_blacklistedInDb = true; + if( entry._retryCount <= 0 ) { re = true; - item->_blacklistedInDb = true; } - // if the retryCount is 0, but the etag has changed, it is tried again + // if the retryCount is 0, but the etag for downloads or the mtime for uploads + // has changed, it is tried again // note that if the retryCount is -1 we never try again. if( entry._retryCount == 0 ) { - if( item->_etag.isEmpty() || entry._lastTryEtag.isEmpty() ) { - // compare the mtimes. - if(entry._lastTryModtime != item->_modtime) { + if( item->_dir == SyncFileItem::Up ) { // check the modtime + if(item->_modtime == 0 || entry._lastTryModtime == 0) { re = false; - qDebug() << item->_file << " is blacklisted, but has changed mtime!"; - + } else { + if( item->_modtime != entry._lastTryModtime ) { + re = false; + qDebug() << item->_file << " is blacklisted, but has changed mtime!"; + } } } else { - if( entry._lastTryEtag != item->_etag) { - re = false; - qDebug() << item->_file << " is blacklisted, but has changed etag!"; + // download, check the etag. + if( item->_etag.isEmpty() || entry._lastTryEtag.isEmpty() ) { + qDebug() << item->_file << "one ETag is empty, no blacklisting"; + return false; + } else { + if( item->_etag != entry._lastTryEtag ) { + re = false; + qDebug() << item->_file << " is blacklisted, but has changed etag!"; + } } } } + if( re ) { qDebug() << "Item is on blacklist: " << entry._file << "retries:" << entry._retryCount; - item->_blacklistedInDb = true; item->_instruction = CSYNC_INSTRUCTION_IGNORE; item->_errorString = tr("The item is not synced because it is on the blacklist."); slotProgress( Progress::SoftError, *item ); @@ -270,15 +280,6 @@ int CSyncThread::treewalkFile( TREE_WALK_FILE *file, bool remote ) int re = 0; - // check for blacklisting of this item. - // if the item is on blacklist, the instruction was set to IGNORE - checkBlacklisting( &item ); - - if (file->instruction != CSYNC_INSTRUCTION_IGNORE - && file->instruction != CSYNC_INSTRUCTION_REMOVE) { - _hasFiles = true; - } - switch(file->instruction) { case CSYNC_INSTRUCTION_NONE: break; @@ -349,6 +350,14 @@ int CSyncThread::treewalkFile( TREE_WALK_FILE *file, bool remote ) } item._dir = dir; + // check for blacklisting of this item. + // if the item is on blacklist, the instruction was set to IGNORE + checkBlacklisting( &item ); + + if (file->instruction != CSYNC_INSTRUCTION_IGNORE + && file->instruction != CSYNC_INSTRUCTION_REMOVE) { + _hasFiles = true; + } _syncedItems.append(item); return re;