[Pkg-owncloud-commits] [owncloud-client] 13/33: Fix adding a file in a Shared readonly directory

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Feb 27 19:44:24 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch upstream
in repository owncloud-client.

commit cd131444150143fbce13040bd601c8f9a1430316
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Fri Feb 21 10:53:09 2014 +0100

    Fix adding a file in a Shared readonly directory
    
    It should not create a conflict in that case.
    
    Also when editing a file, create a conflict using the normal way,
    after downloading the file and checking it is not the same
---
 src/mirall/owncloudpropagator.cpp | 38 ++++++++++++++------------------------
 1 file changed, 14 insertions(+), 24 deletions(-)

diff --git a/src/mirall/owncloudpropagator.cpp b/src/mirall/owncloudpropagator.cpp
index 7368e15..ccf22a4 100644
--- a/src/mirall/owncloudpropagator.cpp
+++ b/src/mirall/owncloudpropagator.cpp
@@ -115,10 +115,17 @@ bool PropagateItemJob::checkForProblemsWithShared(const QString& msg)
 
     if( httpStatusCode == 403 && _propagator->isInSharedDirectory(_item._file )) {
         if( _item._type != SyncFileItem::Directory ) {
-            // the file was removed locally from a read only Shared sync
-            // the file is gone locally and it should be recovered.
             SyncFileItem downloadItem(_item);
-            downloadItem._instruction = CSYNC_INSTRUCTION_SYNC;
+            if (downloadItem._instruction == CSYNC_INSTRUCTION_NEW) {
+                // don't try to recover pushing new files
+                return false;
+            } else if (downloadItem._instruction == CSYNC_INSTRUCTION_SYNC) {
+                // we modified the file locally, jsut create a conflict then
+                downloadItem._instruction = CSYNC_INSTRUCTION_CONFLICT;
+            } else {
+                // the file was removed or renamed, just recover the old one
+                downloadItem._instruction = CSYNC_INSTRUCTION_SYNC;
+            }
             downloadItem._dir = SyncFileItem::Down;
             newJob = new PropagateDownloadFile(_propagator, downloadItem);
         } else {
@@ -152,7 +159,7 @@ void PropagateItemJob::slotRestoreJobCompleted(const SyncFileItem& item )
         _restoreJob->setRestoreJobMsg();
     }
 
-    if( item._status == SyncFileItem::Success ) {
+    if( item._status == SyncFileItem::Success ||  item._status == SyncFileItem::Conflict) {
         done( SyncFileItem::SoftError, msg);
     } else {
         done( item._status, tr("A file or directory was removed from a read only share, but restoring failed: %1").arg(item._errorString) );
@@ -409,26 +416,9 @@ void PropagateUploadFile::start()
                 done( SyncFileItem::SoftError, errMsg );
             } else {
                 // Other HBF error conditions.
-                _item._httpErrorCode = hbf_fail_http_code(trans.data());
-                if( _item._httpErrorCode == 403 && _propagator->isInSharedDirectory(_item._file) ) {
-                    // a read only share file has been modified. Conflict it and
-                    // restore the original file.
-                    QString fn = _propagator->_localDir + _item._file;
-                    QFile f(fn);
-                    QString conflictFileName(fn);
-                    int dotLocation = conflictFileName.lastIndexOf('.');
-
-                    QString timeString = Utility::qDateTimeFromTime_t(_item._modtime).toString("yyyyMMdd-hhmmss");
-                    conflictFileName.insert(dotLocation, "_conflict-" + timeString);
-                    if (!f.rename(conflictFileName)) {
-                        //If the rename fails, don't replace it.
-                        done(SyncFileItem::NormalError, f.errorString());
-                        return;
-                    }
-                    if( checkForProblemsWithShared(tr("The file was edited locally but is part of a read only share. It is restored and your edit is in the conflict file."))) {
-                        return;
-                    }
-                }
+                if(checkForProblemsWithShared(tr("The file was edited locally but is part of a read only share. "
+                                                 "It is restored and your edit is in the conflict file.")))
+                    return;
                 done(SyncFileItem::NormalError, hbf_error_string(trans.data(), state));
             }
             return;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list