[Pkg-owncloud-commits] [owncloud-client] 18/332: Add a recursiveFolderStatus method
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:33 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 2911c0e1c4861756b24e0760ec465f6be4e22586
Author: Klaas Freitag <freitag at owncloud.com>
Date: Mon Jun 2 12:07:24 2014 +0200
Add a recursiveFolderStatus method
---
src/mirall/folder.cpp | 67 +++++++++++++++++++++++++++++++++++++++++----------
src/mirall/folder.h | 12 ++++++++-
2 files changed, 65 insertions(+), 14 deletions(-)
diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index bc0a0c4..78cf1bc 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -719,6 +719,38 @@ void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction direction, bool *
#endif
}
+// compute the file status of a directory recursively. It returns either
+// "all in sync" or "needs update" or "error", no more details.
+SyncFileStatus Folder::recursiveFolderStatus( const QString& fileName )
+{
+ QDir dir(path() + fileName);
+
+ const QStringList dirEntries = dir.entryList( QDir::AllEntries | QDir::NoDotAndDotDot );
+
+ foreach( const QString entry, dirEntries ) {
+ QFileInfo fi(entry);
+ SyncFileStatus sfs;
+ if( fi.isDir() ) {
+ sfs = recursiveFolderStatus( fileName + QLatin1Char('/') + entry );
+ } else {
+ QString fs( fileName + QLatin1Char('/') + entry );
+ if( fileName.isEmpty() ) {
+ // toplevel, no slash etc. needed.
+ fs = entry;
+ }
+ sfs = fileStatus( fs );
+ }
+
+ if( sfs == FILE_STATUS_STAT_ERROR || sfs == FILE_STATUS_ERROR ) {
+ return FILE_STATUS_ERROR;
+ }
+ if( sfs != FILE_STATUS_SYNC) {
+ return FILE_STATUS_EVAL;
+ }
+ }
+ return FILE_STATUS_SYNC;
+}
+
SyncFileStatus Folder::fileStatus( const QString& fileName )
{
/*
@@ -738,7 +770,11 @@ SyncFileStatus Folder::fileStatus( const QString& fileName )
// FIXME: Find a way for STATUS_ERROR
SyncFileStatus stat = FILE_STATUS_NONE;
- QString file = path() + fileName;
+ QString file = fileName;
+ if( path() != QLatin1String("/") ) {
+ file = path() + fileName;
+ }
+
QFileInfo fi(file);
if( !fi.exists() ) {
@@ -762,20 +798,25 @@ SyncFileStatus Folder::fileStatus( const QString& fileName )
}
}
- SyncJournalFileRecord rec = _journal.getFileRecord(fileName);
- if( stat == FILE_STATUS_NONE && !rec.isValid() ) {
- stat = FILE_STATUS_NEW;
- }
-
- // file was locally modified.
- if( stat == FILE_STATUS_NONE && fi.lastModified() != rec._modtime ) {
- stat = FILE_STATUS_EVAL;
- }
+ if( type == CSYNC_FTW_TYPE_DIR ) {
+ // compute recursive status of the directory
+ stat = recursiveFolderStatus( fileName );
+ } else {
+ if( stat == FILE_STATUS_NONE ) {
+ SyncJournalFileRecord rec = _journal.getFileRecord(fileName);
+ if( !rec.isValid() ) {
+ stat = FILE_STATUS_NEW;
+ }
- if( stat == FILE_STATUS_NONE ) {
- stat = FILE_STATUS_SYNC;
+ // file was locally modified.
+ if( stat == FILE_STATUS_NONE && fi.lastModified() != rec._modtime ) {
+ stat = FILE_STATUS_EVAL;
+ }
+ }
+ if( stat == FILE_STATUS_NONE ) {
+ stat = FILE_STATUS_SYNC;
+ }
}
-
return stat;
}
diff --git a/src/mirall/folder.h b/src/mirall/folder.h
index 90f47a9..575b601 100644
--- a/src/mirall/folder.h
+++ b/src/mirall/folder.h
@@ -77,6 +77,17 @@ public:
SyncFileStatus fileStatus( const QString& );
/**
+ * @brief recursiveFolderStatus
+ * @param fileName - the relative file name to examine
+ * @return the resulting status
+ *
+ * The resulting status can only be either SYNC which means all files
+ * are in sync, ERROR if an error occured, or EVAL if something needs
+ * to be synced underneath this dir.
+ */
+ SyncFileStatus recursiveFolderStatus( const QString& fileName );
+
+ /**
* alias or nickname
*/
QString alias() const;
@@ -186,7 +197,6 @@ private slots:
private:
bool init();
-
void setIgnoredFiles();
void bubbleUpSyncResult();
--
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