Revert the changes that fetch the file id in the propagator.

We don't want to fetch the file id in the propagator.

Revert "Put item member variable to base class."
This reverts commit f7aa2aa348.

Revert "Add isValidFileId and getFileIdPropget methods."
This reverts commit ccd254abba.
This commit is contained in:
Olivier Goffart 2013-11-14 13:47:43 +01:00
parent 578431c791
commit e8e27b61f6
2 changed files with 17 additions and 83 deletions

View file

@ -119,11 +119,6 @@ static bool removeRecursively(const QString &path)
return success;
}
static bool isValidFileId( const QString& fid )
{
return ( !fid.isEmpty() && fid != QLatin1String("-invalid_fileid-") );
}
DECLARE_JOB(PropagateLocalRemove)
void PropagateLocalRemove::start()
@ -302,19 +297,19 @@ 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( isValidFileId(_item._fileId ) ) {
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 ) {
qDebug() << "WARN: File ID changed!" << _item._fileId << fid;
} else {
qDebug() << "FileID remains" << _item._fileId;
}
} else {
if( fid.isEmpty() ) {
const char *plain_uri = uri.data();
_item._fileId = getFileId(plain_uri);
} else {
_item._fileId = fid;
}
}
/* Handle errors. */
@ -384,8 +379,6 @@ void PropagateItemJob::updateMTimeAndETag(const char* uri, time_t mtime)
ops[1].name = NULL;
int rc = ne_proppatch( _propagator->_session, uri, ops );
Q_UNUSED(rc);
/* FIXME: error handling
bool error = updateErrorFromSession( rc );
if( error ) {
@ -416,54 +409,9 @@ void PropagateItemJob::updateMTimeAndETag(const char* uri, time_t mtime)
}
}
static void propget_result(void *userdata, const ne_uri *uri,
const ne_prop_result_set *results)
void PropagateItemJob::getFileId(const char* uri)
{
ne_propname ops[2];
ops[0].nspace = "http://owncloud.org/ns";
ops[0].name = "id";
ops[1].nspace = NULL;
ops[1].name = NULL;
(void) uri;
char *file_id = (char*) userdata;
const char *fid = ne_propset_value(results, ops);
if( fid ) {
qMemCopy(file_id, fid, 64);
file_id[strlen(fid)] = '\0';
}
}
QString PropagatorJob::getFileIdPropget(const char *uri)
{
char file_id[65];
ne_propname ops[2];
ops[0].nspace = "http://owncloud.org/ns";
ops[0].name = "id";
ops[1].nspace = NULL;
ops[1].name = NULL;
int rc;
memset(file_id, 0, 65);
rc = ne_simple_propfind( _propagator->_session, uri, NE_DEPTH_ZERO, ops, propget_result, file_id);
QString re;
if( rc != NE_OK ) {
qDebug() << "FileID Propget failed.";
} else {
if( file_id != NULL) {
re = QString::fromUtf8(file_id);
}
}
return re;
}
QString PropagatorJob::getFileId(const char* uri)
{
if( ! uri ) return QString();
QString fid;
if( ! uri ) return;
QScopedPointer<ne_request, ScopedPointerHelpers> req(ne_request_create(_propagator->_session, "HEAD", uri));
qDebug() << "Querying the fileID from " << uri;
@ -472,9 +420,8 @@ QString PropagatorJob::getFileId(const char* uri)
// error happend
qDebug() << "Could not issue HEAD request for FileID.";
} else {
fid = parseFileId( req.data() );
_item._fileId = parseFileId( req.data() );
}
return fid;
}
void PropagateItemJob::limitBandwidth(qint64 progress, qint64 bandwidth_limit)
@ -973,19 +920,6 @@ void PropagateDirectory::proceedNext(SyncFileItem::Status status)
_item._file = _item._renameTarget;
}
// FIXME: Do we really need this here? It updates the file id of directories
// in case it is not valid, due to fact that the journal might not have a
// correct file_id.
// FIXME: Can that be combined with retrieval of the etag?
if( !isValidFileId(_item._fileId)) {
QScopedPointer<char, QScopedPointerPodDeleter> uri(
ne_path_escape((_propagator->_remoteDir + _item._file).toUtf8()));
const char *plain_uri = uri.data();
_item._fileId = getFileIdPropget(plain_uri);
qDebug() << "XX Retrieved directory file id" << _item._fileId;
}
SyncJournalFileRecord record(_item, _propagator->_localDir + _item._file);
_propagator->_journal->setFileRecord(record);
}

View file

@ -36,10 +36,6 @@ class PropagatorJob : public QObject {
Q_OBJECT
protected:
OwncloudPropagator *_propagator;
QString getFileId( const char* url );
QString getFileIdPropget(const char *uri);
SyncFileItem _item;
public:
explicit PropagatorJob(OwncloudPropagator* propagator) : _propagator(propagator) {}
public slots:
@ -63,13 +59,15 @@ public:
//TODO: in the future, all sub job can be run in parallel
QVector<PropagatorJob *> _subJobs;
SyncFileItem _item;
int _current; // index of the current running job
bool _hasError; // weather there was an error
explicit PropagateDirectory(OwncloudPropagator *propagator, const SyncFileItem &item = SyncFileItem())
: PropagatorJob(propagator)
, _firstJob(0), _current(-1), _hasError(false) { _item = item; }
, _firstJob(0), _item(item), _current(-1), _hasError(false) { }
virtual ~PropagateDirectory() {
qDeleteAll(_subJobs);
@ -107,6 +105,7 @@ private slots:
class PropagateItemJob : public PropagatorJob {
Q_OBJECT
protected:
SyncFileItem _item;
void done(SyncFileItem::Status status, const QString &errorString = QString()) {
_item._errorString = errorString;
_item._status = status;
@ -115,6 +114,7 @@ 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.
@ -133,7 +133,7 @@ protected:
public:
PropagateItemJob(OwncloudPropagator* propagator, const SyncFileItem &item)
: PropagatorJob(propagator), _lastProgress(0) { _item = item; }
: PropagatorJob(propagator), _item(item), _lastProgress(0) {}
};
// Dummy job that just mark it as completed and ignored.