[Pkg-owncloud-commits] [owncloud-client] 318/498: Sync: Store information about ignored files on the server in database.

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Aug 11 14:49:02 UTC 2015


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 b0aedef4b01d63114e168f661b0c6f760c17c33c
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Thu Jul 9 15:57:56 2015 +0200

    Sync: Store information about ignored files on the server in database.
    
    That allows better handling of remove requests that should not be done
    because the directory is not empty on the remote side (as it contains
    ignored files).
---
 csync/src/csync.c                     |  1 +
 csync/src/csync.h                     |  3 +++
 csync/src/csync_statedb.c             |  5 ++++-
 src/libsync/filesystem.cpp            |  3 +++
 src/libsync/syncengine.cpp            |  5 ++++-
 src/libsync/syncfileitem.h            |  3 ++-
 src/libsync/syncjournaldb.cpp         | 20 ++++++++++++++++----
 src/libsync/syncjournalfilerecord.cpp |  4 ++--
 src/libsync/syncjournalfilerecord.h   | 11 ++++++-----
 9 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/csync/src/csync.c b/csync/src/csync.c
index 095809a..985e084 100644
--- a/csync/src/csync.c
+++ b/csync/src/csync.c
@@ -435,6 +435,7 @@ static int _csync_treewalk_visitor(void *obj, void *data) {
 
       trav.error_status = cur->error_status;
       trav.should_update_metadata = cur->should_update_metadata;
+      trav.has_ignored_files = cur->has_ignored_files;
 
       if( other_node ) {
           csync_file_stat_t *other_stat = (csync_file_stat_t*)other_node->data;
diff --git a/csync/src/csync.h b/csync/src/csync.h
index 97eb981..99e3695 100644
--- a/csync/src/csync.h
+++ b/csync/src/csync.h
@@ -250,6 +250,9 @@ struct csync_tree_walk_file_s {
     /* For directories: If the etag has been updated and need to be writen on the db */
     int         should_update_metadata;
 
+    /* For directories: Does it have children that were ignored (hidden or ignore pattern) */
+    int         has_ignored_files;
+
     const char *rename_path;
     const char *etag;
     const char *file_id;
diff --git a/csync/src/csync_statedb.c b/csync/src/csync_statedb.c
index 779bb34..c951fe9 100644
--- a/csync/src/csync_statedb.c
+++ b/csync/src/csync_statedb.c
@@ -283,6 +283,9 @@ static int _csync_file_stat_from_metadata_table( csync_file_stat_t **st, sqlite3
             if(column_count > 12 && sqlite3_column_int64(stmt,12)) {
                 (*st)->size = sqlite3_column_int64(stmt, 12);
             }
+            if(column_count > 13) {
+                (*st)->has_ignored_files = sqlite3_column_int(stmt, 13);
+            }
         }
     } else {
         if( rc != SQLITE_DONE ) {
@@ -435,7 +438,7 @@ char *csync_statedb_get_etag( CSYNC *ctx, uint64_t jHash ) {
     return ret;
 }
 
-#define BELOW_PATH_QUERY "SELECT phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm, filesize FROM metadata WHERE pathlen>? AND path LIKE(?)"
+#define BELOW_PATH_QUERY "SELECT phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm, filesize, ignoredChildrenRemote FROM metadata WHERE pathlen>? AND path LIKE(?)"
 
 int csync_statedb_get_below_path( CSYNC *ctx, const char *path ) {
     int rc;
diff --git a/src/libsync/filesystem.cpp b/src/libsync/filesystem.cpp
index 62484fc..f299d1f 100644
--- a/src/libsync/filesystem.cpp
+++ b/src/libsync/filesystem.cpp
@@ -105,6 +105,9 @@ void FileSystem::setFileHidden(const QString& filename, bool hidden)
             SetFileAttributesW((wchar_t*)fName.utf16(), dwAttrs & ~FILE_ATTRIBUTE_HIDDEN );
         }
     }
+#else
+    Q_UNUSED(filename);
+    Q_UNUSED(hidden);
 #endif
 }
 
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 2ceb6c1..53fb7df 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -350,6 +350,9 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
     }
     item->_should_update_metadata = item->_should_update_metadata || file->should_update_metadata;
 
+    item->_hasIgnoredFiles    = file->has_ignored_files > 0 ? true : false;
+    qDebug() << "HAS IGNORED FILES for " << item->_file << item->_hasIgnoredFiles << key;
+
     // record the seen files to be able to clean the journal later
     _seenFiles.insert(item->_file);
     if (!renameTarget.isEmpty()) {
@@ -426,7 +429,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
         item->_type = SyncFileItem::UnknownType;
     }
 
-    SyncFileItem::Direction dir;
+    SyncFileItem::Direction dir = SyncFileItem::None;
 
     int re = 0;
     switch(file->instruction) {
diff --git a/src/libsync/syncfileitem.h b/src/libsync/syncfileitem.h
index 0f4c401..8c2b933 100644
--- a/src/libsync/syncfileitem.h
+++ b/src/libsync/syncfileitem.h
@@ -64,7 +64,7 @@ public:
     };
 
     SyncFileItem() : _type(UnknownType),  _direction(None), _isDirectory(false),
-        _hasBlacklistEntry(false), _status(NoStatus),
+        _hasIgnoredFiles(false), _hasBlacklistEntry(false), _status(NoStatus),
         _isRestoration(false), _should_update_metadata(false),
         _httpErrorCode(0), _requestDuration(0), _affectedItems(1),
         _instruction(CSYNC_INSTRUCTION_NONE), _modtime(0), _size(0), _inode(0)
@@ -130,6 +130,7 @@ public:
     Type _type BITFIELD(3);
     Direction _direction BITFIELD(2);
     bool _isDirectory BITFIELD(1);
+    bool _hasIgnoredFiles BITFIELD(1);
 
     /// Whether there's an entry in the blacklist table.
     /// Note: that entry may have retries left, so this can be true
diff --git a/src/libsync/syncjournaldb.cpp b/src/libsync/syncjournaldb.cpp
index f75fdb9..4801c86 100644
--- a/src/libsync/syncjournaldb.cpp
+++ b/src/libsync/syncjournaldb.cpp
@@ -346,13 +346,13 @@ bool SyncJournalDb::checkConnect()
     }
 
     _getFileRecordQuery.reset(new SqlQuery(_db));
-    _getFileRecordQuery->prepare("SELECT path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm, filesize FROM "
+    _getFileRecordQuery->prepare("SELECT path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm, filesize, ignoredChildrenRemote FROM "
                                  "metadata WHERE phash=?1" );
 
     _setFileRecordQuery.reset(new SqlQuery(_db) );
     _setFileRecordQuery->prepare("INSERT OR REPLACE INTO metadata "
-                                 "(phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm, filesize) "
-                                 "VALUES (?1 , ?2, ?3 , ?4 , ?5 , ?6 , ?7,  ?8 , ?9 , ?10, ?11, ?12, ?13);" );
+                                 "(phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm, filesize, ignoredChildrenRemote) "
+                                 "VALUES (?1 , ?2, ?3 , ?4 , ?5 , ?6 , ?7,  ?8 , ?9 , ?10, ?11, ?12, ?13, ?14);" );
 
     _getDownloadInfoQuery.reset(new SqlQuery(_db) );
     _getDownloadInfoQuery->prepare( "SELECT tmpfile, etag, errorcount FROM "
@@ -516,6 +516,16 @@ bool SyncJournalDb::updateMetadataTableStructure()
         commitInternal("update database structure: add pathlen index");
 
     }
+
+    if( columns.indexOf(QLatin1String("ignoredChildrenRemote")) == -1 ) {
+        SqlQuery query(_db);
+        query.prepare("ALTER TABLE metadata ADD COLUMN ignoredChildrenRemote INT;");
+        if( !query.exec()) {
+            sqlFail("updateMetadataTableStructure: add ignoredChildrenRemote column", query);
+            re = false;
+        }
+        commitInternal("update database structure: add ignoredChildrenRemote col");
+    }
     return re;
 }
 
@@ -630,6 +640,7 @@ bool SyncJournalDb::setFileRecord( const SyncJournalFileRecord& _record )
         _setFileRecordQuery->bindValue(11, fileId );
         _setFileRecordQuery->bindValue(12, remotePerm );
         _setFileRecordQuery->bindValue(13, record._fileSize );
+        _setFileRecordQuery->bindValue(14, record._hasIgnoredFiles ? 1:0);
 
         if( !_setFileRecordQuery->exec() ) {
             qWarning() << "Error SQL statement setFileRecord: " << _setFileRecordQuery->lastQuery() <<  " :"
@@ -640,7 +651,7 @@ bool SyncJournalDb::setFileRecord( const SyncJournalFileRecord& _record )
         qDebug() <<  _setFileRecordQuery->lastQuery() << phash << plen << record._path << record._inode
                  << record._mode
                  << QString::number(Utility::qDateTimeToTime_t(record._modtime)) << QString::number(record._type)
-                 << record._etag << record._fileId << record._remotePerm << record._fileSize;
+                 << record._etag << record._fileId << record._remotePerm << record._fileSize << (record._hasIgnoredFiles ? 1:0);
 
         _setFileRecordQuery->reset();
         return true;
@@ -719,6 +730,7 @@ SyncJournalFileRecord SyncJournalDb::getFileRecord( const QString& filename )
             rec._fileId  = _getFileRecordQuery->baValue(8);
             rec._remotePerm = _getFileRecordQuery->baValue(9);
             rec._fileSize   = _getFileRecordQuery->int64Value(10);
+            rec._hasIgnoredFiles = _getFileRecordQuery->intValue(11) > 0 ? true : false;
         } else {
             QString err = _getFileRecordQuery->error();
             qDebug() << "No journal entry found for " << filename;
diff --git a/src/libsync/syncjournalfilerecord.cpp b/src/libsync/syncjournalfilerecord.cpp
index 01cefe4..8bca298 100644
--- a/src/libsync/syncjournalfilerecord.cpp
+++ b/src/libsync/syncjournalfilerecord.cpp
@@ -28,14 +28,14 @@
 namespace OCC {
 
 SyncJournalFileRecord::SyncJournalFileRecord()
-    :_inode(0), _type(0), _fileSize(0), _mode(0)
+    :_inode(0), _type(0), _fileSize(0), _mode(0), _hasIgnoredFiles(false)
 {
 }
 
 SyncJournalFileRecord::SyncJournalFileRecord(const SyncFileItem &item, const QString &localFileName)
     : _path(item._file), _modtime(Utility::qDateTimeFromTime_t(item._modtime)),
       _type(item._type), _etag(item._etag), _fileId(item._fileId), _fileSize(item._size),
-      _remotePerm(item._remotePerm), _mode(0)
+      _remotePerm(item._remotePerm), _mode(0), _hasIgnoredFiles(item._hasIgnoredFiles)
 {
     // use the "old" inode coming with the item for the case where the
     // filesystem stat fails. That can happen if the the file was removed
diff --git a/src/libsync/syncjournalfilerecord.h b/src/libsync/syncjournalfilerecord.h
index be5f7d6..b18a2ab 100644
--- a/src/libsync/syncjournalfilerecord.h
+++ b/src/libsync/syncjournalfilerecord.h
@@ -37,15 +37,16 @@ public:
         return !_path.isEmpty();
     }
 
-    QString   _path;
-    quint64   _inode;
-    QDateTime _modtime;
-    int       _type;
+    QString    _path;
+    quint64    _inode;
+    QDateTime  _modtime;
+    int        _type;
     QByteArray _etag;
     QByteArray _fileId;
     qint64     _fileSize;
     QByteArray _remotePerm;
-    int       _mode;
+    int        _mode;
+    bool       _hasIgnoredFiles;
 };
 
 bool OWNCLOUDSYNC_EXPORT

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