From kde-commits Thu Feb 03 15:41:11 2011 From: Klaas Freitag Date: Thu, 03 Feb 2011 15:41:11 +0000 To: kde-commits Subject: branches/work/sharedkraft/src Message-Id: <20110203154111.C2FDD3E1F5 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129674770327075 SVN commit 1218653 by freitag: Mostly documenting the numbercycle download process M +34 -2 kraftdoc.cpp --- branches/work/sharedkraft/src/kraftdoc.cpp #1218652:1218653 @@ -248,6 +248,32 @@ // Called in sharedKraft mode, when the kitoc object received the answer from the // owncloud and parsed it. This one must generate the ident and save it to the // file. +/* + The secure handling of the cloud Ids is: + 1. Without having a kitoc id, the document is saved under a local tuple id + which is supposed to be unique locally, ie. the username and DB unique id. + 2. If the new Id arrives, the file is updated by writing to temp file (ie. + filename.newxml) + * delete the index database entry + * move the file to the right filename + * create the db index entry with the right modified time of the file + 3. The file has a new modified time than. The index algorithm has to realise + that on krafts startup and updates the index in the database. + + Error cases: + a) Documents have no Kitoc doc id - they are only local + - ask the server for an id for the user-localID tuple. Either the user + generates it for the localID or resends a previously generated. + b) there are new-files (filename.newxml) That means that the moving has not + happened. + - Ask the kitoc server again for the number and redo. + - the modified time of a file is different from the one in the index table. + Regenerate the index. + c) there is no index entry in the database for a file or the modified time is + wrong + - regenerate the index. +*/ + void KraftDoc::slotReceivedId() { int nextId = mKitoc->nextId(); @@ -258,14 +284,20 @@ QString oldIdent = ident(); setIdent( id ); - // save again. + // save again, using the updated id. + bool result = false; DocumentSaverBase *saver = getSaver(); if( saver ) { - bool result = saver->saveDocument( this ); + result = saver->saveDocument( this ); } else { kDebug() << "ERR: could not get a saver"; } + if( result ) { + // the new file was created, remove the old one. + + } + // update the index again }