Keep the updater data in the log struct for the synclog.

Also, shorten the timestamp and add the sync direction.
This commit is contained in:
Klaas Freitag 2014-04-03 16:56:36 +02:00
parent 565bb540d6
commit cf87fdff7f
5 changed files with 54 additions and 21 deletions

View file

@ -137,7 +137,7 @@ void PropagateRemoteRemove::start()
// Wed, 15 Nov 1995 06:25:24 GMT
QDateTime dt = QDateTime::currentDateTimeUtc();
_item._responseTimeStamp = dt.toString("ddd, dd MMM yyyy hh:mm:ss GMT");
_item._responseTimeStamp = dt.toString("hh:mm:ss");
_propagator->_journal->deleteFileRecord(_item._originalFile, _item._isDirectory);
_propagator->_journal->commit("Remote Remove");
@ -158,7 +158,7 @@ void PropagateRemoteMkdir::start()
* Ignore that error */
// Wed, 15 Nov 1995 06:25:24 GMT
QDateTime dt = QDateTime::currentDateTimeUtc();
_item._responseTimeStamp = dt.toString("ddd, dd MMM yyyy hh:mm:ss GMT");
_item._responseTimeStamp = dt.toString("hh:mm:ss");
if( updateErrorFromSession( rc , 0, 405 ) ) {
return;
@ -248,7 +248,7 @@ void PropagateRemoteRename::start()
}
// Wed, 15 Nov 1995 06:25:24 GMT
QDateTime dt = QDateTime::currentDateTimeUtc();
_item._responseTimeStamp = dt.toString("ddd, dd MMM yyyy hh:mm:ss GMT");
_item._responseTimeStamp = dt.toString("hh:mm:ss");
_propagator->_journal->deleteFileRecord(_item._originalFile);
SyncJournalFileRecord record(_item, _propagator->_localDir + _item._renameTarget);

View file

@ -368,11 +368,17 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
}
_needsUpdate = true;
item.other._etag = file->other.etag;
item.other._fileId = file->other.file_id;
item.other._instruction = file->other.instruction;
item.other._modtime = file->other.modtime;
item.other._size = file->other.size;
item.log._etag = file->etag;
item.log._fileId = file->file_id;
item.log._instruction = file->instruction;
item.log._modtime = file->modtime;
item.log._size = file->size;
item.log._other_etag = file->other.etag;
item.log._other_fileId = file->other.file_id;
item.log._other_instruction = file->other.instruction;
item.log._other_modtime = file->other.modtime;
item.log._other_size = file->other.size;
_syncedItems.append(item);
emit syncItemDiscovered(item);

View file

@ -99,7 +99,12 @@ public:
QByteArray _etag;
QByteArray _fileId;
enum csync_instructions_e _instruction;
} other;
quint64 _other_size;
time_t _other_modtime;
QByteArray _other_etag;
QByteArray _other_fileId;
enum csync_instructions_e _other_instruction;
} log;
};

View file

@ -11,6 +11,8 @@
* for more details.
*/
#include <QRegExp>
#include "mirall/syncrunfilelog.h"
#include "mirall/utility.h"
#include "mirall/mirallconfigfile.h"
@ -28,6 +30,17 @@ QString SyncRunFileLog::dateTimeStr( const QDateTime& dt )
return dt.toString(Qt::ISODate);
}
QString SyncRunFileLog::directionToStr( SyncFileItem::Direction dir )
{
QString re("N");
if( dir == SyncFileItem::Up ) {
re = QLatin1String("Up");
} else if( dir == SyncFileItem::Down ) {
re = QLatin1String("Down");
}
return re;
}
QString SyncRunFileLog::instructionToStr( csync_instructions_e inst )
{
QString re;
@ -104,7 +117,7 @@ void SyncRunFileLog::start(const QString &folderPath, const Utility::StopWatch
if (!exists) {
// We are creating a new file, add the note.
_out << "# timestamp | duration | file | instruction | modtime | etag | "
_out << "# timestamp | duration | file | instruction | dir | modtime | etag | "
"size | fileId | status | errorString | http result code | "
"other size | other modtime | other etag | other fileId | "
"other instruction" << endl;
@ -123,24 +136,32 @@ void SyncRunFileLog::logItem( const SyncFileItem& item )
if( item._direction == SyncFileItem::None ) {
return;
}
QString ts = item._responseTimeStamp;
if( ts.length() > 6 ) {
QRegExp rx("(\\d\\d:\\d\\d:\\d\\d)");
if( ts.contains(rx) ) {
ts = rx.cap(0);
}
}
const QChar L = QLatin1Char('|');
_out << item._responseTimeStamp << L;
_out << ts << L;
_out << QString::number(item._requestDuration) << L;
_out << item._file << L;
_out << instructionToStr( item._instruction ) << L;
_out << QString::number(item._modtime) << L;
_out << item._etag << L;
_out << QString::number(item._size) << L;
_out << item._fileId << L;
_out << instructionToStr( item.log._instruction ) << L;
_out << directionToStr( item._direction ) << L;
_out << QString::number(item.log._modtime) << L;
_out << item.log._etag << L;
_out << QString::number(item.log._size) << L;
_out << item.log._fileId << L;
_out << item._status << L;
_out << item._errorString << L;
_out << QString::number(item._httpErrorCode) << L;
_out << QString::number(item.other._size) << L;
_out << QString::number(item.other._modtime) << L;
_out << item.other._etag << L;
_out << item.other._fileId << L;
_out << instructionToStr(item.other._instruction) << L;
_out << QString::number(item.log._other_size) << L;
_out << QString::number(item.log._other_modtime) << L;
_out << item.log._other_etag << L;
_out << item.log._other_fileId << L;
_out << instructionToStr(item.log._other_instruction) << L;
_out << endl;
}

View file

@ -37,6 +37,7 @@ protected:
private:
QString dateTimeStr( const QDateTime& dt );
QString instructionToStr( csync_instructions_e inst );
QString directionToStr( SyncFileItem::Direction dir );
QScopedPointer<QFile> _file;
QTextStream _out;