Do not fetch the file id in the propagator with a HEAD

Normally, the fileid comes with the PUT or the GET.
If it did not comes with the PUT, it means the server do not support
fileid,  we should not query it with a useless HEAD.

Also, in case the fileid changes (which it should not)  update anyway
to the new fileid in the db
This commit is contained in:
Olivier Goffart 2013-11-15 10:14:06 +01:00
Родитель 36e8273da0
Коммит b3972a5ba8
2 изменённых файлов: 4 добавлений и 26 удалений

Просмотреть файл

@ -297,19 +297,13 @@ void PropagateUploadFile::start()
// the file id should only be empty for new files up- or downloaded
QString fid = QString::fromUtf8( hbf_transfer_file_id( trans.data() ));
if( _item._fileId.isEmpty() ) {
if( fid.isEmpty() ) {
const char *plain_uri = uri.data();
getFileId(plain_uri);
} else {
_item._fileId = fid;
}
} else {
if( _item._fileId != fid ) {
if( !fid.isEmpty() ) {
if( !_item._fileId.isEmpty() && _item._fileId != fid ) {
qDebug() << "WARN: File ID changed!" << _item._fileId << fid;
} else {
qDebug() << "FileID remains" << _item._fileId;
qDebug() << "FileID is" << fid;
}
_item._fileId = fid;
}
/* Handle errors. */
@ -409,21 +403,6 @@ void PropagateItemJob::updateMTimeAndETag(const char* uri, time_t mtime)
}
}
void PropagateItemJob::getFileId(const char* uri)
{
if( ! uri ) return;
QScopedPointer<ne_request, ScopedPointerHelpers> req(ne_request_create(_propagator->_session, "HEAD", uri));
qDebug() << "Querying the fileID from " << uri;
int neon_stat = ne_request_dispatch(req.data());
if( neon_stat != NE_OK ) {
// error happend
qDebug() << "Could not issue HEAD request for FileID.";
} else {
_item._fileId = parseFileId( req.data() );
}
}
void PropagateItemJob::limitBandwidth(qint64 progress, qint64 bandwidth_limit)
{
if (bandwidth_limit > 0) {

Просмотреть файл

@ -114,7 +114,6 @@ protected:
}
void updateMTimeAndETag(const char *uri, time_t);
void getFileId( const char *uri );
/* fetch the error code and string from the session
in case of error, calls done with the error and returns true.