[Pkg-owncloud-commits] [owncloud-client] 178/211: SocketAPI: Show error when we are not allowed

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:42 UTC 2014


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

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

commit e46ab72718cb7be7daf28cb80d3cc8f1b0755133
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Wed Oct 22 17:13:34 2014 +0200

    SocketAPI:  Show error when we are not allowed
    
    Issue #1931
---
 src/mirall/socketapi.cpp | 28 +++++++++++++++++++++++++++-
 src/mirall/socketapi.h   |  1 -
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/mirall/socketapi.cpp b/src/mirall/socketapi.cpp
index f558097..d0806e1 100644
--- a/src/mirall/socketapi.cpp
+++ b/src/mirall/socketapi.cpp
@@ -558,7 +558,11 @@ SyncFileStatus SocketApi::fileStatus(Folder *folder, const QString& systemFileNa
             if( FileSystem::getModTime(fi.absoluteFilePath()) == Utility::qDateTimeToTime_t(rec._modtime) ) {
                 status.set(SyncFileStatus::STATUS_SYNC);
             } else {
-                status.set(SyncFileStatus::STATUS_EVAL);
+                if (rec._remotePerm.isNull() || rec._remotePerm.contains("W") ) {
+                    status.set(SyncFileStatus::STATUS_EVAL);
+                } else {
+                    status.set(SyncFileStatus::STATUS_ERROR);
+                }
             }
         } else {
             qDebug() << Q_FUNC_INFO << "Could not determine state for file" << fileName << "will set STATUS_NEW";
@@ -577,6 +581,28 @@ SyncFileStatus SocketApi::fileStatus(Folder *folder, const QString& systemFileNa
             status.setSharedWithMe(true);
         }
     }
+    if (status.tag() == SyncFileStatus::STATUS_NEW) {
+        // check the parent folder if it is shared and if it is allowed to create a file/dir within
+        QDir d( fi.path() );
+        auto parentPath = d.path();
+        auto dirRec = dbFileRecord_capi(folder, parentPath);
+        bool isDir = type == CSYNC_FTW_TYPE_DIR;
+        while( !d.isRoot() && !(d.exists() && dirRec.isValid()) ) {
+            d.cdUp(); // returns true if the dir exists.
+
+            parentPath = d.path();
+            // cut the folder path
+            dirRec = dbFileRecord_capi(folder, parentPath);
+
+            isDir = true;
+        }
+        if( dirRec.isValid() && !dirRec._remotePerm.isNull()) {
+            if( (isDir && !dirRec._remotePerm.contains("K"))
+                    || (!isDir && !dirRec._remotePerm.contains("C")) ) {
+                status.set(SyncFileStatus::STATUS_ERROR);
+            }
+        }
+    }
     return status;
 }
 
diff --git a/src/mirall/socketapi.h b/src/mirall/socketapi.h
index 24460bd..2f3446e 100644
--- a/src/mirall/socketapi.h
+++ b/src/mirall/socketapi.h
@@ -65,7 +65,6 @@ private slots:
 
 private:
     SyncFileStatus fileStatus(Folder *folder, const QString& systemFileName, c_strlist_t *excludes );
-    SyncJournalFileRecord dbFileRecord( Folder *folder, QString fileName );
     SyncJournalFileRecord dbFileRecord_capi( Folder *folder, QString fileName );
     SyncFileStatus recursiveFolderStatus(Folder *folder, const QString& fileName, c_strlist_t *excludes  );
     SqlQuery *getSqlQuery( Folder *folder );

-- 
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